2 #error This file should not be compiled with Wine.
11 /* allocate some tmp string space */
12 /* FIXME: this is not 100% thread-safe */
13 static char *get_temp_buffer( size_t size
)
15 static char *list
[32];
20 idx
= InterlockedExchangeAdd( &pos
, 1 ) % (sizeof(list
)/sizeof(list
[0]));
21 if ((ret
= realloc( list
[idx
], size
))) list
[idx
] = ret
;
26 /* release unused part of the buffer */
27 static void release_temp_buffer( char *buffer
, size_t size
)
29 /* don't bother doing anything */
34 /* printf with temp buffer allocation */
35 const char *wine_dbg_sprintf( const char *format
, ... )
37 static const int max_size
= 200;
42 va_start(valist
, format
);
43 ret
= get_temp_buffer( max_size
);
44 len
= vsnprintf( ret
, max_size
, format
, valist
);
45 if (len
== -1 || len
>= max_size
) ret
[max_size
-1] = 0;
46 else release_temp_buffer( ret
, len
+ 1 );
51 /* default implementation of wine_dbgstr_wn */
52 const char *wine_dbgstr_wn( const WCHAR
*str
, int n
)
57 if (!((ULONG_PTR
)str
>> 16))
59 if (!str
) return "(null)";
60 res
= get_temp_buffer( 6 );
61 sprintf( res
, "#%04x", LOWORD(str
) );
66 const WCHAR
*end
= str
;
71 size
= 12 + min( 300, n
* 5 );
72 dst
= res
= get_temp_buffer( size
);
75 while (n
-- > 0 && dst
<= res
+ size
- 10)
80 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
81 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
82 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
83 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
84 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
86 if (c
>= ' ' && c
<= 126)
91 sprintf(dst
,"%04x",c
);
104 release_temp_buffer( res
, dst
- res
);