Re: auto-apt-0.3.22 hurd patch (PATH_MAX)
Here are my immediate comment.s Other people might have a different
On Thu, 2012-01-26 at 13:21 +0100, Tanguy LE CARROUR wrote:
> As I'm waiting for feed back on the memstat-0.9, I've started to work
> on auto-apt-0.3.22. It uses PATH_MAX in 2 functions.
> 1) I fixed pkg_intern() but malloc is in a while loop so each time I
> malloc/free the buffer.... there may be a smartest way to do it only
> once before the while... but I don't know how!
You can use the construct:
char *buf = NULL;
if (buf != NULL)
and then free(buf) after last iteration.
Depends on if the same buffer is changing size or if you need a new
buffer every time. For the first case I think you can use realloc() and
in the second case the above construct.
> 2) The problem in pkg_symbol() is a bit different. The dynamically
> allocated buffer is the return value of the function, so I cannot free
> it in the function. The rest of the code that uses this buffer never
> frees it!
> Am I supposed to fix each part of the code that uses this function to
> free the returned buffer?!
Yes, you need to free the buffer in the calling program(s).