Re: [AD] sys_directx_trace_handler

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 4/28/05, guilt <karthikkumar@xxxxxxxxxx> wrote:
> in wsystem.c i'm seeing this:
>  
>  /* thread_safe_trace:
>  * Outputs internal trace message.
>  */
> void thread_safe_trace(
> char *msg,...)
> {
>  char buf[256];
>  va_list ap;
> 
>  /* todo, some day: use vsnprintf (C99) */
>  va_start(ap, msg);
> 
>  vsprintf(buf, msg, ap);
>  va_end(ap);
> 
>  OutputDebugString(buf); /* thread safe */
> }
>  :)
>  
>  could help ...
> 

This is a little OT, but wouldn't vasprintf be a better choice? Its
simple enough to write yourself if a system doesn't support it
(*cough* windows *cough*), I actually did just that. See sprintf(NULL,
...); is speced to return the length of the string it would have
created had there been a place to write it to. Then you just malloc
some memory, and sprintf it in, or snprintf, but since we are sure of
the length, sprintf won't hurt anything.

And this is completely OT: is it just me,  or does gmail syntax
highlight code? :o

-- 
Thomas Fjellstrom
http://www.strangesoft.net
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/