Finished the complain() migration.
This commit is contained in:
parent
8067dc76b7
commit
aafb27cb2c
|
@ -13,6 +13,10 @@ extern void *uiAlloc(size_t, const char *);
|
||||||
extern void *uiRealloc(void *, size_t, const char *);
|
extern void *uiRealloc(void *, size_t, const char *);
|
||||||
extern void uiFree(void *);
|
extern void uiFree(void *);
|
||||||
|
|
||||||
|
// ugh, this was only introduced in MSVC 2015...
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define __func__ __FUNCTION__
|
||||||
|
#endif
|
||||||
extern void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
extern void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
||||||
#define _ns2(s) #s
|
#define _ns2(s) #s
|
||||||
#define _ns(s) _ns2(s)
|
#define _ns(s) _ns2(s)
|
||||||
|
|
|
@ -13,20 +13,15 @@ void initAlloc(void)
|
||||||
|
|
||||||
void uninitAlloc(void)
|
void uninitAlloc(void)
|
||||||
{
|
{
|
||||||
BOOL hasEntry;
|
std::ostringstream oss;
|
||||||
|
|
||||||
hasEntry = FALSE;
|
if (heap.size() == 0)
|
||||||
for (const auto &alloc : heap) {
|
return;
|
||||||
if (!hasEntry) {
|
for (const auto &alloc : heap)
|
||||||
fprintf(stderr, "[libui] leaked allocations:\n");
|
// note the void * cast; otherwise it'll be treated as a string
|
||||||
hasEntry = TRUE;
|
oss << (void *) (alloc.first) << " " << types[alloc.second] << "\n";
|
||||||
}
|
// TODO keep oss.str() alive?
|
||||||
fprintf(stderr, "[libui] %p %s\n",
|
userbug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", oss.str().c_str());
|
||||||
alloc.first,
|
|
||||||
types[alloc.second]);
|
|
||||||
}
|
|
||||||
if (hasEntry)
|
|
||||||
complain("either you left something around or there's a bug in libui");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define rawBytes(pa) (&((*pa)[0]))
|
#define rawBytes(pa) (&((*pa)[0]))
|
||||||
|
|
|
@ -41,7 +41,6 @@ HRESULT _logLastError(debugargs, const WCHAR *s)
|
||||||
|
|
||||||
HRESULT _logHRESULT(debugargs, const WCHAR *s, HRESULT hr)
|
HRESULT _logHRESULT(debugargs, const WCHAR *s, HRESULT hr)
|
||||||
{
|
{
|
||||||
DWORD le;
|
|
||||||
WCHAR *msg;
|
WCHAR *msg;
|
||||||
WCHAR *formatted;
|
WCHAR *formatted;
|
||||||
BOOL useFormatted;
|
BOOL useFormatted;
|
||||||
|
@ -73,7 +72,7 @@ void realbug(const char *file, const char *line, const char *func, const char *p
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
n++; // terminating '\0'
|
n++; // terminating '\0'
|
||||||
|
|
||||||
buf = (char *) uiAlloc(n * sizeof (char), "char[]");
|
msg = (char *) uiAlloc(n * sizeof (char), "char[]");
|
||||||
// includes terminating '\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
// includes terminating '\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
||||||
vsprintf_s(msg, n, format, ap);
|
vsprintf_s(msg, n, format, ap);
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,13 @@ static const char *initerr(const char *message, const WCHAR *label, DWORD value)
|
||||||
if (!hassysmsg)
|
if (!hassysmsg)
|
||||||
sysmsg = L"";
|
sysmsg = L"";
|
||||||
wmessage = toUTF16(message + 1);
|
wmessage = toUTF16(message + 1);
|
||||||
wout = debugstrf(L"-error initializing libui: %s; code %I32d (0x%08I32X) %s",
|
wout = strf(L"-error initializing libui: %s; code %I32d (0x%08I32X) %s",
|
||||||
wmessage,
|
wmessage,
|
||||||
value, value,
|
value, value,
|
||||||
sysmsg);
|
sysmsg);
|
||||||
uiFree(wmessage);
|
uiFree(wmessage);
|
||||||
if (hassysmsg)
|
if (hassysmsg)
|
||||||
LocalFree(sysmsg); // ignore error
|
LocalFree(sysmsg); // ignore error
|
||||||
if (wout == NULL) // debugstrf() failed; return message raw
|
|
||||||
return message + 1;
|
|
||||||
out = toUTF8(wout);
|
out = toUTF8(wout);
|
||||||
uiFree(wout);
|
uiFree(wout);
|
||||||
return out + 1;
|
return out + 1;
|
||||||
|
|
|
@ -47,4 +47,5 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue