Re: [PATCH 1/1] mmap.2: improve example

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

 



On 06/03/2016 02:46 AM, Rahul Bedarkar wrote:
> Hello Michael,
> 
> On Fri, Jun 3, 2016 at 4:59 AM, Michael Kerrisk (man-pages)
> <mtk.manpages@xxxxxxxxx> wrote:
>> Hello Rahul,
>>
>>
>> Given that handle_error() calls exit(), and that triggers close()
>> on all FDs and munmap() on all mappings, I'm not sure this patch
>> improves things. Can you say some more on why you think it is
>> needed?
> 
> I think it is always better to free resources after use to avoid
> memory leaks later. But doing that in such
> simple example might be debatable.

Yep.

> May be at-least at the end we should call munmap() and close(). That
> will cover munmap() usage as well.

Yes, by way of example, I think it doesn't hurt to add the munmap() 
call especially. Added.

Thanks for the input.

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux