On 09/29/2010 04:29 PM, Nikola Pajkovsky wrote:
On 09/29/2010 03:22 PM, Jiri Moskovcak wrote:
> On 09/29/2010 01:17 PM, Nikola Pajkovsky wrote:
>> Signed-off-by: Nikola Pajkovsky<npajkovs(a)redhat.com>
>> ---
>> inc/xfuncs.h | 1 +
>> lib/utils/xfuncs.c | 8 ++++++++
>> 2 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/inc/xfuncs.h b/inc/xfuncs.h
>> index 0be1f80..2028456 100644
>> --- a/inc/xfuncs.h
>> +++ b/inc/xfuncs.h
>> @@ -33,6 +33,7 @@ int ndelay_on(int fd);
>> int ndelay_off(int fd);
>> int close_on_exec_on(int fd);
>>
>> +void* xcalloc(size_t nmemb, size_t size);
>> void* xmalloc(size_t size);
>> void* xrealloc(void *ptr, size_t size);
>> void* xzalloc(size_t size);
>> diff --git a/lib/utils/xfuncs.c b/lib/utils/xfuncs.c
>> index 7179637..9d17d3d 100644
>> --- a/lib/utils/xfuncs.c
>> +++ b/lib/utils/xfuncs.c
>> @@ -39,6 +39,14 @@ int close_on_exec_on(int fd)
>> return fcntl(fd, F_SETFD, FD_CLOEXEC);
>> }
>>
>> +void *xcalloc(size_t nmemb, size_t size)
>> +{
>> + void *ptr = calloc(nmemb, size);
>> + if (!ptr&& (!nmemb || !size))
>
> - I think you want if (!ptr&& (!nmemb&& !size))
>
Nope. NULL may also be returned by a successful call to malloc() with a size of zero,
or by a successful call to calloc() with nmemb *or* size equal to zero.
exactly and it's not "out of memory" problem
>> + die_out_of_memory();
>> + return ptr;
>> +}
>> +
>> // Die if we can't allocate size bytes of memory.
>> void* xmalloc(size_t size)
>> {
>
> _______________________________________________
> Crash-catcher mailing list
> Crash-catcher(a)lists.fedorahosted.org
>
https://fedorahosted.org/mailman/listinfo/crash-catcher