[Ecls-list] alloc.d questions

Vadim Konovalov vadrer at gmail.com
Sun May 18 20:15:18 UTC 2008


I decided to create a perl module for embedding with ECLs and things are going 
quite smooth.

There are some questions however, and developer documentation seemingly do not 
cover them.

first, all functions to convert char* -> cl_object use strlen, as documented. 
This means no \0 char allowed within strings. How this could be avoided?

More important question - what if I want to return memory back.

There is a function dealloc, which takes a pointer to memory and integer, and 
the function itself frightened me a lot.

I cite it here for convenience:

cl_dealloc(void *p, cl_index s)
        struct contblock **cbpp, *cbp;

        if (s < CBMINSIZE)
        cbp = (struct contblock *)p;
        cbp->cb_size = s;
        for (cbpp = &cb_pointer; *cbpp != NULL; cbpp = &((*cbpp)->cb_link))
                if ((*cbpp)->cb_size >= s) {
                        cbp->cb_link = *cbpp;
                        *cbpp = cbp;
        cbp->cb_link = NULL;
        *cbpp = cbp;

First, must the programmer track memory chunk size for himself?

Secondly, CBMINSIZE is 64 bytes and all chunks of this size will be thrown 
away?? isn't this a source for memory leaks?

Thirdy, the 'for' loop within a code makes freeing memory O(N) operation. It 
is just simply a source for unexpected slowdowns within complicated runs.

Fourthly,  if defined GBC_BOEHM, then cl_dealloc dummied away?

#ifdef GBC_BOEHM
#define cl_dealloc(p,s)

FWIW allocator should be improved, but I do not know how :)
I do know that allocator within perl5 is very efficient and it could be used 
for reference. It's interface is quite siple and I even suceeded re-using 
perl5 allocator for Tcl and gained significant performance!

All in all, when not considering alloc.d, the overall impression is very good 
for the LISP novice like me :)

Best regards,

More information about the ecl-devel mailing list