This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] malloc: Add posix_memalign test.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]