[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Devel] memory leak in open_face()
From: |
Werner LEMBERG |
Subject: |
Re: [Devel] memory leak in open_face() |
Date: |
Tue, 20 May 2003 22:09:36 +0200 (CEST) |
Sorry for the late reply.
> I experienced a strange problem trying to build fontconfig on my
> laptop. It has 160M RAM & fc-cache ran out of memory during 'make
> install'. I turned a swap on & figured out that it allocates about
> 180M (I used standard & cyrillic fonts shipped with XFree86 4.2.1
> only). I debugged the stuff & found the bug in src/base/ftobjs.c
> (freetype-2.1.3).
Are you really sure that FreeType is the problem? You should perhaps
run valgrind to find where the memory leaks are.
> I debugged the stuff & found the bug in src/base/ftobjs.c
> (freetype-2.1.3). The code contains gotos for error handling ( I
> consider it to be not that good ;) ),
For error handling it is usually the best solution if you want to
write C code which compiles to a library as small as possible.
> but FT_FREE is called in the case clazz->init_face() is failed only.
> 'error' variable contains an unpredictable value if the 1st or the
> 2nd 'goto Fail' is used (initializing it with a null value on
> declaration is a good idea i guess). I provided the code with my
> suggestions marked with '++' signs below.
This is not true. The FT_ALLOC and FT_NEW macros implicitly set the
`error' variable. Anyway, there was a small bug: open_face() tried to
free `face->internal' instead of `internal' directly; the former can
cause a segfault. Fixed in the CVS.
Werner
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Devel] memory leak in open_face(),
Werner LEMBERG <=