diff options
| author | miod <> | 2014-05-26 20:54:06 +0000 | 
|---|---|---|
| committer | miod <> | 2014-05-26 20:54:06 +0000 | 
| commit | ff902a2ab8de41d828e44691e4fcd5e828a0ee2c (patch) | |
| tree | c839ab4f405bfea1c43fddd81eb73b59b27f5ef3 /src/lib/libc/stdlib/malloc.c | |
| parent | bc3247c8eb23411aa06a89056f623998745a0bb5 (diff) | |
| download | openbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.tar.gz openbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.tar.bz2 openbsd-ff902a2ab8de41d828e44691e4fcd5e828a0ee2c.zip | |
Replace the following logic:
        if (nothing to allocate)
                ptr = malloc(1)
        else {
                if ((ptr = malloc(size to allocate))
                        memcpy(ptr, data to copy, size to allocate)
        }
        if (ptr == NULL)
                OMG ERROR
with a saner logic where the NULL pointer check if moved to the actual
malloc branch, so that we do not need to malloc a single byte, just to avoid
having a NULL pointer.
Whoever thought allocating a single byte was a smart idea was obviously
not taking his meds.
ok beck@ guenther@
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
0 files changed, 0 insertions, 0 deletions
