[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libredwg] Memory dellocation

From: Rodrigo Rodrigues da Silva
Subject: [libredwg] Memory dellocation
Date: Mon, 09 Aug 2010 19:27:07 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100713 Thunderbird/3.0.6

Hi folks,

I've been thinking for a while (since writing the first lines of code)
that libredwg is a big memory leak. Memory is allocated but never freed.
There are 2 options, AFAIK:

1. dellocate memory manually. I thought about using dwg.spec +
redefining the decode.c macros, using free when a malloc has been used
in decode.c, to create a void dwg_free (Dwg_Data* data) function.

2. use libgc (garbage collector), allocate everything with GC_MALLOC()
and never think about deallocation again.

Option 1 seems cumbersome to maintain. Some /mallocs/ are used outside
of macros/spec scope. Besides, the users have to be instructed to always
dwg_free() - specially bad in a (still) hypothetic situation where the
user is using libredwg through python bindings.

Option 2 seems too 'easy' and weird. Is it common to use a garbage
collector inside a library? If the client program uses libgc as well, is
that possible that lib and program conflict?

Please let me know what you think.

Rodrigo Rodrigues da Silva

PoliGNU - Grupo de Estudos de Software Livre da Poli/USP
GNU Project

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]