[PATCH:libXt 2/4] Add XtAsprintf() to Alloc.c & Intrinsic.h

walter harms wharms at bfs.de
Wed Dec 15 00:16:00 PST 2010



Am 14.12.2010 19:36, schrieb Alan Coopersmith:
> walter harms wrote:
>>
>> Am 14.12.2010 01:40, schrieb Alan Coopersmith:
>>> Like asprintf() but using XtMalloc() to tie into the Xt memory allocation
>>> and error handling subsystems.
>>
>> should that have a "#ifndef HAVE_ASPRINTF" ? when the system has asprintf why no use it ?
> 
> Because the system asprintf() uses malloc, and we need to use XtMalloc() so
> that the Xt error handlers are called on failure (notice that Xt never checks
> for failure, since failure in Xt is considered fatal, but the program can
> provide an error handler for cleanup before exiting), and so that programs
> can call XtFree() on the returned string without worrying about which memory
> allocation library was used to allocate it (apparently a bigger problem on
> Windows, but I can build Unix environments with different memory allocators
> for different libraries - I just don't recommend trying it).
> 

ok, i understand XtMalloc() will never fail.

re,
 wh


More information about the xorg-devel mailing list