vext01/libdefile — comment on commit 1ffde1bb0c708374079a6e9b22252c93e5b39167
File:  line 0
By haesbaert:

On 25 October 2011 16:17, Edd Barrett

wrote:
> On Tue, Oct 25, 2011 at 11:12:13AM -0700, Christiano F. Haesbaert wrote:
>> I beg to disagree, the pointer is lost, so it's a leak. If you free it
>> before reassigning, I'm ok.
>
> Bah, yes. My bad. Sorry.
>
>> But then I don't see any point in heap allocing something which is
>> kept in a global state and can only come from a constant define or
>> from argv[].
>
> but can you do: some_struct.member = "string literal" ?
>>

Sure you can, string literals go to the data segment and they are read-only.

>> > But strictly speaking, the buffer is not freed, you are right. But
>> > then *nothing* is freed when you exit due to errors either.
>> >
>> > I am not sure what the correct thing to do is. In my other project I
>> > never used err/errx, and just returned an error state which eventually
>> > frees *everything* that was ever heap allocated. However, I rarely see
>> > this in bsd code.
>>
>> Sure when you call err/errx/exit there is no problem, everything gets freed.
>> The thing is that you *lose* a pointer, you lose the reference for
>> something which is malloced, and that is wrong.
>>
>> >
>> > Thoughts?
>> >
>>
>> Please don't get me wrong, I'm not bitching, remember when I wanted to
>> have df_state heap alloced so I didn't need to use the '.' instead of
>> the '->' ? and you said people would raise eyebrowns ? This is the
>> same thing, plus the leak.
>>
>> Also have in mind that having a magic_file in df_state is wrong, since
>> we'll need to support multiple magic_files, as the current file does:
>>
>> file -f /etc/magic:mymagic:/etc/balbalblab and so on.
>>
>> --
>> Reply to this email directly or view it on GitHub:
>> https://github.com/vext01/libdefile/commit/1ffde1bb0c708374079a6e9b22252c93e5b39167#commitcomment-673939
>
> --
> Best Regards
> Edd Barrett
>
> http://www.theunixzoo.co.uk
>
> --
> Reply to this email directly or view it on GitHub:
> https://github.com/vext01/libdefile/commit/1ffde1bb0c708374079a6e9b22252c93e5b39167#commitcomment-673956
>