[DGD]Using DGD_STRING_NEW correctly...
Felix A. Croes
felix at dworkin.nl
Fri Jun 22 22:17:40 CEST 2001
"Michael J. Bacon" <mj.bacon at gte.net> wrote:
> I think I am doing something "bad" with DGD_STRING_NEW because I'm creating
> memory leaks like crazy. :-)
>
> In an extension I have a loop that is creating a lot of strings and adding
> them to a mapping. To do this I call DGD_STRING_NEW repeatedly. ie...
>
> while (field != NULL)
> str = DGD_STRING_NEW(field->name, strlen(field->name));
> DGD_STRING_PUTVAL(nameval, str);
> str2 = DGD_STRING_NEW(field->data, strlen(field->data));
> DGD_STRING_PUTVAL(fieldval, str2);
> DGD_MAPPING_ASSIGN(data, map, nameval, fieldval);
>
> ... lots of stuff edited out but this gives you the gist of what creates
> the problem I think. When this function has finished there are a bunch of
> leaked strings.
There is a `{' missing after the first line.
Regards,
Dworkin
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list