[PATCH 2/4] xkb: Remove superfluous if(x) x = realloc(x, sz); else x = malloc(sz); logic
keithp at keithp.com
Fri Jun 4 10:06:21 PDT 2010
> Why did anyone write the code like that to begin with? Did the
> behavior or realloc not allow this at some point in the past?
Yes. On most systems, both realloc and free would crash if passed NULL.
Combine that with malloc(0) returning NULL on some systems and you get
the fine behaviour
t = malloc(0);
free(t); <- segfault
This might give you some idea of why the malloc wrappers existed in the
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the xorg-devel