On 01/31/2012 09:53 PM, Richard W.M. Jones wrote:
On Tue, Jan 31, 2012 at 09:39:17PM +0800, Wanlong Gao wrote:
> On 01/31/2012 09:30 PM, Richard W.M. Jones wrote:
>
>> On Tue, Jan 31, 2012 at 06:19:32PM +0800, Wanlong Gao wrote:
>>> The strdup/strndup() introduces malloc() to allocate memory,
>>> so we need to free them carefully.
>>
>> I'm not sure this patch is necessary.
>>
>> We already check for memory leaks in many utilities (in 'make
>> extra-tests'), but we only do it for the success case. If the utility
>> fails, it's better that it just exits as soon as possible, even if it
>> doesn't free all memory along the way.
>
>
> But I wonder that if fail, where will the allocated memory go? not a leak?
The operating system recovers memory from all processes that call
_exit(2). There is no need to free any of it.
But we do want to know if the library is leaking memory, which would
be a problem for people using libguestfs, which is why we perform leak
tests in the non-failure case.
Yes, I see, only shared memory and temp files exist after the process' lifetime.
thanks for you explanation Rich.
-Wanlong Gao
[...]
> make extra-tests can test virt-format, too, it seems not?
It's tested:
Makefile.am: $(RUN_VG) ../../format/virt-format -a test1.img >/dev/null
Rich.