From 3fc36ec58228f244f841f6ff8953cbbbfea9f350 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 7 Apr 2015 22:54:21 -0400 Subject: [PATCH] More allocation logging. I wonder if I can just log directly in the allocators themselves... --- new/container_unix.c | 1 - new/uipriv.h | 4 ++++ new/window_darwin.m | 1 + new/window_unix.c | 3 ++- new/window_windows.c | 3 ++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/new/container_unix.c b/new/container_unix.c index f923931..099944b 100644 --- a/new/container_unix.c +++ b/new/container_unix.c @@ -17,7 +17,6 @@ static void uiContainer_dispose(GObject *obj) static void uiContainer_finalize(GObject *obj) { -printf("in uiContainer_finalize(); freeing container\n"); G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj); } diff --git a/new/uipriv.h b/new/uipriv.h index ccd72e8..30fca00 100644 --- a/new/uipriv.h +++ b/new/uipriv.h @@ -2,6 +2,10 @@ #include #include "ui.h" +#include +#define LOGALLOC(p, ty) fprintf(stderr, "%p %s ALLOC\n", p, #ty ); +#define LOGFREE(p, ty) fprintf(stderr, "%p %s FREE\n", p, #ty ); + typedef struct uiSize uiSize; typedef struct uiSizing uiSizing; diff --git a/new/window_darwin.m b/new/window_darwin.m index 8beb008..a5f1b2d 100644 --- a/new/window_darwin.m +++ b/new/window_darwin.m @@ -40,6 +40,7 @@ uiWindow *uiNewWindow(char *title, int width, int height) uiWindow *w; w = (uiWindow *) uiAlloc(sizeof (uiWindow)); +LOGALLOC(w, uiWindow) w->w = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask) diff --git a/new/window_unix.c b/new/window_unix.c index 9f61289..734b156 100644 --- a/new/window_unix.c +++ b/new/window_unix.c @@ -12,7 +12,7 @@ static void onDestroy(GtkWindow *window, gpointer data) { uiWindow *w = (uiWindow *) data; -printf("destroying window; freeing uiWindow\n"); +LOGFREE(w, uiWindow) uiFree(w); } @@ -21,6 +21,7 @@ uiWindow *uiNewWindow(char *title, int width, int height) uiWindow *w; w = uiNew(uiWindow); +LOGALLOC(w, uiWindow) w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(w->widget), title); gtk_window_resize(GTK_WINDOW(w->widget), width, height); diff --git a/new/window_windows.c b/new/window_windows.c index ed2cea3..50e7a88 100644 --- a/new/window_windows.c +++ b/new/window_windows.c @@ -46,7 +46,7 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA return 0; break; // fall through to DefWindowProcW() case WM_DESTROY: -printf("destroying window; freeing uiWindow\n"); +LOGFREE(w, uiWindow) uiFree(w); break; // fall through to DefWindowProcW() } @@ -82,6 +82,7 @@ uiWindow *uiNewWindow(char *title, int width, int height) WCHAR *wtitle; w = uiNew(uiWindow); +LOGALLOC(w, uiWindow) w->onClosing = defaultOnClosing; adjust.left = 0;