[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
unnecessary {de,}alloc wrappers?
From: |
Ondrej Oprala |
Subject: |
unnecessary {de,}alloc wrappers? |
Date: |
Tue, 01 Apr 2014 17:28:43 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
Hi,
Could someone please explain to me, why are xrealloc and xfree (or
more specifically - their parts) from lib/malloc/xmalloc.c necessary?
e.g.
if (string)
free(string);
Why is this needed? AFAIK the C standard specifies free(NULL) is
completely legal.
Also:
temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
Again, the C standard says that realloc(0, bytes) is equivalent to
malloc(bytes).
So why check for these cases?
Thanks,
Ondrej
- unnecessary {de,}alloc wrappers?,
Ondrej Oprala <=