Re: [PATCH 4/5] Match FREE and MALLOC/STRDUP/REALLOC

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

 



On Thu, 2021-11-18 at 10:46 +0800, lixiaokeng wrote:
> 
> 
> On 2021/11/18 8:47, Benjamin Marzinski wrote:
> > On Tue, Nov 16, 2021 at 10:00:53PM +0800, lixiaokeng wrote:
> > > In _DEBUG_ mode, MALLOC/STRDUP/REALLOC and FREE will record
> > > the memory usage. Match them.
> > 
> > This looks fine, but personally, I'd rather just have all the DEBUG
> > memory code removed. If people want to check memory usage, there's
> > always valgrind.
> > 
> > -Ben
> > 
> > > 
> 
> If MALLOC/STRDUP/REALLOC and FREE is unnecessary, I'll remove this
> patch
> in this series and make a patch remove them latter. What is Martin's
> opinion?

As you saw, I agree with Ben. If you want to make a major contribution,
prepare a patch that gets rid of all those. :-) 

Just note that MALLOC() is really calloc(). 

The only one that that's useful in non-debug mode is FREE(), because it
sets the pointer to NULL, avoiding double-free. Therefore a patch
replacing FREE() with free() would need to assess where that's
necessary (basically always if the data structure that holds the
pointer lives on after the free() call).

Regards
Martin


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux