Re: auto-apt-0.3.22 hurd patch (PATH_MAX)
- To: Tanguy LE CARROUR <firstname.lastname@example.org>
- Cc: email@example.com
- Subject: Re: auto-apt-0.3.22 hurd patch (PATH_MAX)
- From: Jérémie Koenig <firstname.lastname@example.org>
- Date: Thu, 26 Jan 2012 21:22:19 +0100
- Message-id: <CA+kCSAbd+D+bLjw=Njq2cFnUAxFYOrAxWknW57KnwCXMowURBQ@mail.gmail.com>
- In-reply-to: <CAJbrmLD+s=wqLf6nwRy_2e00zF7-4=NkjDXE-vEk6vp4BbBZBw@mail.gmail.com>
- References: <CAJbrmLD+s=wqLf6nwRy_2e00zF7-4=NkjDXE-vEk6vp4BbBZBw@mail.gmail.com>
On Thu, Jan 26, 2012 at 1:21 PM, Tanguy LE CARROUR
> 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?!
Presumably the returned buffer is static.
You could use a static pointer to a buffer which is reallocated on
each call; from the exterior the semantics would be close to
static char *buf = NULL;
buf = realloc(buf, whatever size is required this time);
You'll be fine as long as the calling code does not assume the
function returns a constant pointer.
Jérémie Koenig <email@example.com>