On Thu, Jan 01, 2004 at 07:17:24PM +0100, Marcus Holland-Moritz wrote:
| On 2004-01-01, at 17:42:17 +0000, [EMAIL PROTECTED] wrote:
| 
| > Second, I have a XS producing strings. Do I need to free them? I ask this
| > because the scripts keeps increasing the memory used (although I'm not 
| > storing any information at all).
| 
| What do you mean by "producing strings"?
| Could you please show us the relevant parts of the XS code?

Of course :)

char*
wlgetbyid(id, word)
         int id
         U32 word
   INIT:
         char* str;
   CODE:
         if (id > MAXDICS || id < 0 || !wln[id]) {
             str = g_strdup("");
         } else {
             str = word_list_get_by_id(wln[id], word);
             if (!str) str = g_strdup("(null)");
         }
         RETVAL = str;
   OUTPUT:
         RETVAL

Here, str is "(null)" from the strdup or another string (returned by
the word_list_get_by_id). Both of them must be freed.

Best,
Alberto

| 
| Probably the solution to your problem is as easy as adding a
| call to sv_2mortal() in the right place.
| 
| Marcus
| 
| -- 
| Time is an illusion perpetrated by the manufacturers of space.

-- 
Departamento de Informatica - Universidade do Minho

"The C Programming Language -- A language which combines the
flexibility of assembly language with the power of assembly language."

Reply via email to