[plt-scheme] MzScheme extension

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Mon May 29 06:33:45 EDT 2006

Hi,

I have created an MzScheme extension. In the extension one of the
arguments of a function is a string. In the C code I write this:

Scheme_Object *obj;
char *str;

obj = scheme_char_string_to_byte_string(arg[2]);
str = SCHEME_BYTE_STR_VAL(obj);

My questions:

- I assume that obj is handled by MzScheme and I do not have to free
its memory, as the GC will do that once I return from the C function. 
Is that right?

- Who "owns" the memory of str? Once I am done with the string
do I have to free it or it is also handled by the GC?

- Another related question: Can I use malloc, calloc in the C fcuntions 
for my own data? What I mean that inside a function I allocate some
memory and before the function returns I also free it up. Is that OK
for MzScheme?

Generally what I am concerned about, that I do not want to leak 
any memory in the extension. (However I have variable length
data structures.)

Thanks for any help.

Peter Ivanyi


_______________________________________________________________________________
Lakások már 3 milliótól! – http://ingatlanapro.origo.hu/




Posted on the users mailing list.