| Would it be possible to add functions to the API that allow creating
named memory areas ? This would make it possible for opcodes to
have global variables without the need for changing the ENVIRON
structure (it contains many variables that are only used by specific
opcodes, and it is still not complete and there are static globals
in many files that would need to be moved to ENVIRON).
Of course, this method is slower than having direct access to ENVIRON,
but the name lookup can be made reasonably fast by the use of trees
or hash tables, if it is only done by the opcode at i-time.
It would be easy to implement, here are some example API function
prototypes. csoundCreateGlobalVariable() is called at plugin initialization,
and all the created areas are automatically deleted when the csound instance
is destroyed.
/* allocate nbytes bytes of memory that can be accessed later by calling */
/* csoundQueryGlobalVariable() with the specified name; the space is */
/* cleared to zero */
/* returns zero on success, or a non-zero error code if the name is already */
/* in use or there is not enough memory */
int csoundCreateGlobalVariable(void *csound, const char *name, size_t nbytes);
/* get pointer to space allocated with the name 'name' */
/* returns NULL if the specified name is not defined */
void *csoundQueryGlobalVariable(void *csound, const char *name);
/* free memory allocated for 'name' and remove 'name' from the database */
/* returns zero on success, or a non-zero error code if the name is */
/* not defined */
int csoundDestroyGlobalVariable(void *csound, const char *name);
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |