🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.graphics.avs
Article #211

Re: Allocating memory fro strings

#211
From: Larry Gelberg
Date: Thu, 15 Oct 1992 12:53
76 lines
3559 bytes
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 =========================
Technical Details
Message-ID: <1992Oct15.125312.15413@sol.ctr.columbia.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!aurora!larryg
References: <1992Oct15.095550.28643@alf.uib.no>

Show Full Headers
Complete Article Headers
Newsgroups: comp.graphics.avs
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!aurora!larryg
From: larryg@avs.com (Larry Gelberg)
Subject: Re: Allocating memory fro strings
Organization: Advanced Visual Systems Inc.
References: <1992Oct15.095550.28643@alf.uib.no>
Message-ID: <1992Oct15.125312.15413@sol.ctr.columbia.edu>
Sender: nobody@ctr.columbia.edu
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
Lines: 76