2 #error This file should not be compiled with Wine.
12 /* allocate some tmp string space */
13 /* FIXME: this is not 100% thread-safe */
14 static char *get_temp_buffer( size_t size
)
16 static char *list
[32];
21 idx
= InterlockedExchangeAdd( &pos
, 1 ) % (sizeof(list
)/sizeof(list
[0]));
22 if ((ret
= realloc( list
[idx
], size
))) list
[idx
] = ret
;
27 /* release unused part of the buffer */
28 static void release_temp_buffer( char *buffer
, size_t size
)
30 /* don't bother doing anything */
35 /* printf with temp buffer allocation */
36 const char *wine_dbg_sprintf( const char *format
, ... )
38 static const int max_size
= 200;
43 va_start(valist
, format
);
44 ret
= get_temp_buffer( max_size
);
45 len
= vsnprintf( ret
, max_size
, format
, valist
);
46 if (len
== -1 || len
>= max_size
) ret
[max_size
-1] = 0;
47 else release_temp_buffer( ret
, len
+ 1 );
52 /* default implementation of wine_dbgstr_wn */
53 const char *wine_dbgstr_wn( const WCHAR
*str
, int n
)
58 if (!((ULONG_PTR
)str
>> 16))
60 if (!str
) return "(null)";
61 res
= get_temp_buffer( 6 );
62 sprintf( res
, "#%04x", LOWORD(str
) );
67 const WCHAR
*end
= str
;
72 size
= 12 + min( 300, n
* 5 );
73 dst
= res
= get_temp_buffer( size
);
76 while (n
-- > 0 && dst
<= res
+ size
- 10)
81 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
82 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
83 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
84 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
85 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
87 if (c
>= ' ' && c
<= 126)
92 sprintf(dst
,"%04x",c
);
105 release_temp_buffer( res
, dst
- res
);
109 const char *debugstr_guid( const GUID
*id
)
111 if (!id
) return "(null)";
112 if (!((ULONG_PTR
)id
>> 16)) return wine_dbg_sprintf( "<guid-0x%04hx>", (WORD
)(ULONG_PTR
)id
);
113 return wine_dbg_sprintf( "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
114 id
->Data1
, id
->Data2
, id
->Data3
,
115 id
->Data4
[0], id
->Data4
[1], id
->Data4
[2], id
->Data4
[3],
116 id
->Data4
[4], id
->Data4
[5], id
->Data4
[6], id
->Data4
[7] );