Re: [PATCH v2 4/7] var: adjust memory allocation for strings

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

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:

> From: "brian m. carlson" <bk2204@xxxxxxxxxx>
>
> Right now, all of our values are constants whose allocation is managed
> elsewhere.  However, in the future, we'll have some variables whose
> memory we will need to free.  To keep things consistent, let's make each
> of our functions allocate its own memory and make the caller responsible
> for freeing it.
>
> Signed-off-by: brian m. carlson <bk2204@xxxxxxxxxx>
> ---
>  builtin/var.c | 45 +++++++++++++++++++++++++++++----------------
>  1 file changed, 29 insertions(+), 16 deletions(-)

Making everybody allocate like this patch does is also fine, but
FWIW, with [3/7], we can selectively set ".need_free = 1" for
minority of elements in the array that returns an allocated piece of
memory without making the source code too noisy (as the array
elements for existing majority can omit ".need_free = 0" and leave
it to the default initialization), so I am not opposed to the "we
set .need_free bit only for those that we allocate" approach taken
with the previous round.

Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux