This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] malloc: Add posix_memalign test.
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 02 Oct 2013 13:57:23 -0300
- Subject: Re: [PATCH v2] malloc: Add posix_memalign test.
- Authentication-results: sourceware.org; auth=none
- References: <523042B4 dot 90602 at linaro dot org> <524C4D9E dot 3070701 at redhat dot com>
On 02-10-2013 13:45, Carlos O'Donell wrote:
> Will,
>
> Thanks for the additional test case.
>
> Some comments below, there are some things that
> should get fixed up.
>
>> + if (ret == ENOMEM && p != NULL)
>> + merror ("returned an error but pointer was modified");
>> +
> OK.
>
> Needs free (p).
>From my point of view, there is no need in calling free on a NULL ponter. In fact
free(NULL) will only call the malloc hook, if any, and still in this case I don't
see it needed. It also aplies for other cases where you require the free().
>
>> + ret = posix_memalign (&p, sizeof (void *), 0);
>> +
>> + if (ret != 0 || p == NULL)
>> + merror ("posix_memalign (&p, sizeof (void *), 0) failed.");
>> +
>> + free (p);
> OK.
>
>> +
> Test case needs comment e.g.
> /* Test that a multiple of sizeof(void *) but not a power of two, fails. */
>
> Should set p to NULL (for later free).
Also, posix_memalign disconsider the value of '*memptr', so I also think it is not needed
to really sets it to NULL.