[racket] scheme_make_vector gc macros
We are experiencing some small memory leaks in Fluxus, and I am
wondering if the garbage collector registration of the following code is
right. It should return an array of float values as a scheme vector.
I read the part on memory allocation in Inside: Racket C API, but I'm
not sure how it should be done properly.
Scheme_Object *FloatsToScheme(float *src, unsigned int size)
{
Scheme_Object *ret=NULL;
Scheme_Object *tmp=NULL;
MZ_GC_DECL_REG(2);
MZ_GC_VAR_IN_REG(0, ret);
MZ_GC_VAR_IN_REG(1, tmp);
MZ_GC_REG();
ret = scheme_make_vector(size, scheme_void);
for (unsigned int n=0; n<size; n++)
{
tmp=scheme_make_double(src[n]);
SCHEME_VEC_ELS(ret)[n]=tmp;
}
MZ_GC_UNREG();
return ret;
}
Any help would be greatly appreciated.
Best,
Gabor