From: larryg@avs.com (Larry Gelberg)
Subject: Re: Allocating memory fro strings
Organization: Advanced Visual Systems Inc.
X-Newsreader: Tin 1.1 PL4
Date: Thu, 15 Oct 1992 12:53:12 GMT
X-Posted-From: aurora.avs.com
NNTP-Posting-Host: sol.ctr.columbia.edu

You don't need to allocate any memory at all since it has already 
been allocated by the input port.  You only need to point to it. 
Here is an example (lifted from the 'file browser' module source).

=====================  CUT HERE =====================================
/* mod_gen Version 1                                                     */
/* Module Name: "string example" (Input) (Subroutine)                    */
/* Author: Larry Gelberg                                                 */
/* Date Created: Thu Oct 15 08:45:47 1992                                */
/*                                                                       */
/* This file is automatically generated by the Module Generator (mod_gen)*/
/* Please do not modify or move the contents of this comment block as    */
/* mod_gen needs it in order to read module sources back in.             */
/*                                                                       */
/* output 0 "string out" string                                          */
/* param 0 "filename" browser "" "" ":"                                  */
/* End of Module Description Comments                                    */

#include <stdio.h>
#include <avs/avs.h>
#include <avs/port.h>
 
/* *****************************************/
/*  Module Description                     */
/* *****************************************/
int string_example_desc()
{
	int in_port, out_port, param;
	extern int string_example_compute();

	AVSset_module_name("string example", MODULE_DATA);

	/* Output Port Specifications              */
	out_port = AVScreate_output_port("string out", "string");

	/* Parameter Specifications                */
	param = AVSadd_parameter("filename", "string", 0, 0, "");
	AVSconnect_widget(param, "browser");

	AVSset_compute_proc(string_example_compute);
	return(1);
}
 
/* *****************************************/
/* Module Compute Routine                  */
/* *****************************************/
int string_example_compute( string_out, filename)
	char **string_out;
	char *filename;
{

/* ----> START OF USER-SUPPLIED CODE SECTION #3 (COMPUTE ROUTINE BODY)   */
	*string_out = filename;
/* <---- END OF USER-SUPPLIED CODE SECTION #3                            */
	return(1);
}
 
/* ***********************************************************************/
/* Initialization for modules contained in this file.                    */
/* ***********************************************************************/
int ((*mod_list[])()) = {
	string_example_desc,
};
#define NMODS (sizeof(mod_list) / sizeof(char *))

AVSinit_modules()
{
	AVSinit_from_module_list(mod_list, NMODS);
}
 
=====================  CUT HERE =====================================
--
=== Larry Gelberg ============================ larryg@avs.com =======
      Advanced Visual Systems Inc. (AVS Inc.)
      300 Fifth Ave, Waltham, MA 02154
===== Tel: 617-890-4300 = Fax: 617-890-8287 =========================