[PATCH 2/4] xkb: Remove superfluous if(x) x = realloc(x, sz); else x = malloc(sz); logic
Keith Packard
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
server...
--
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100604/e99c0fd3/attachment.pgp>
More information about the xorg-devel
mailing list