diff --git a/darwin/alloc.m b/darwin/alloc.m index 8f539af7..c445aaee 100644 --- a/darwin/alloc.m +++ b/darwin/alloc.m @@ -12,8 +12,6 @@ void *uiAlloc(size_t size, const char *type) abort(); } memset(out, 0, size); - if (options.debugLogAllocations) - fprintf(stderr, "%p alloc %s\n", out, type); return out; } @@ -29,8 +27,6 @@ void *uiRealloc(void *p, size_t size, const char *type) abort(); } // TODO zero the extra memory - if (options.debugLogAllocations) - fprintf(stderr, "%p realloc %p\n", p, out); return out; } @@ -39,6 +35,4 @@ void uiFree(void *p) if (p == NULL) return; free(p); - if (options.debugLogAllocations) - fprintf(stderr, "%p free\n", p); } diff --git a/darwin/button.m b/darwin/button.m index 7ec5f6ac..b05c65f3 100644 --- a/darwin/button.m +++ b/darwin/button.m @@ -13,8 +13,6 @@ @implementation uipButtonDelegate -uiLogObjCClassAllocations - - (IBAction)buttonClicked:(id)sender { (*(self->onClicked))(self->b, self->onClickedData); diff --git a/darwin/checkbox.m b/darwin/checkbox.m index 94927cb8..7d210f5f 100644 --- a/darwin/checkbox.m +++ b/darwin/checkbox.m @@ -13,8 +13,6 @@ @implementation uipCheckboxDelegate -uiLogObjCClassAllocations - - (IBAction)checkboxToggled:(id)sender { (*(self->onToggled))(self->c, self->onToggledData); diff --git a/darwin/container.m b/darwin/container.m index 2223fd9c..7cf30a05 100644 --- a/darwin/container.m +++ b/darwin/container.m @@ -14,8 +14,6 @@ @implementation containerView -// TODO allocation logger - - (void)setContainer:(uiContainer *)cc { self->c = cc; diff --git a/darwin/menu.m b/darwin/menu.m index cee049d6..ee19a0b4 100644 --- a/darwin/menu.m +++ b/darwin/menu.m @@ -28,8 +28,6 @@ enum { @implementation menuManager -// TODO allocation logger - - (id)init { self = [super init]; diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 54fa863f..b4d4187e 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -9,22 +9,6 @@ #define toNSString(str) [NSString stringWithUTF8String:(str)] #define fromNSString(str) [(str) UTF8String] -#define uiLogObjCClassAllocations \ -+ (id)alloc \ -{ \ - id thing; \ - thing = [super alloc]; \ - if (options.debugLogAllocations) \ - fprintf(stderr, "%p alloc %s\n", thing, [[self className] UTF8String]); \ - return thing; \ -} \ -- (void)dealloc \ -{ \ - [super dealloc]; \ - if (options.debugLogAllocations) \ - fprintf(stderr, "%p free\n", self); \ -} - // These are based on measurements from Interface Builder. // These seem to be based on Auto Layout constants, but I don't see an API that exposes these... #define macXMargin 20 diff --git a/darwin/window.m b/darwin/window.m index 459ffd2a..1b18852c 100644 --- a/darwin/window.m +++ b/darwin/window.m @@ -12,8 +12,6 @@ @implementation windowDelegate -// TODO allocation logging - - (void)setuiWindow:(uiWindow *)ww { self->w = ww; diff --git a/leaks.awk b/leaks.awk deleted file mode 100644 index 1d19ea88..00000000 --- a/leaks.awk +++ /dev/null @@ -1,56 +0,0 @@ -# 7 april 2015 - -$2 == "alloc" { - if ($1 in A) { - problem($1 " already allocated (" A[$1] "); allocated at " NR) - next - } - A[$1] = type() - next -} - -$2 == "realloc" { - if (!($1 in A)) { - problem($1 " not yet allocated; reallocated at " NR) - next - } - if ($3 in A) { - problem($3 " already allocated (" A[$3] "); reallocated at " NR) - next - } - t = A[$1] - delete A[$1] - A[$3] = t - next -} - -$2 == "free" { - if (!($1 in A)) { - problem($1 " not yet allocated; freed at " NR) - next - } - delete A[$1] - next -} - -{ problem("unrecognized line " $0 " at " NR) } - -END { - for (i in A) - problem("leaked " A[i] " at " i) - close("/dev/stderr") - if (hasProblems) - exit 1 -} - -function problem(s) { - print s > "/dev/stderr" - hasProblems = 1 -} - -function type( s, i) { - s = $3 - for (i = 4; i <= NF; i++) - s = s " " $i - return s -} diff --git a/test/main.c b/test/main.c index c5ee60c5..d030ea82 100644 --- a/test/main.c +++ b/test/main.c @@ -27,9 +27,7 @@ int main(int argc, char *argv[]) memset(&o, 0, sizeof (uiInitOptions)); for (i = 1; i < argc; i++) - if (strcmp(argv[i], "leaks") == 0) - o.debugLogAllocations = 1; - else { +{//TODO else { fprintf(stderr, "%s: unrecognized option %s\n", argv[0], argv[i]); return 1; } diff --git a/ui.idl b/ui.idl index 8149154b..05e1e56a 100644 --- a/ui.idl +++ b/ui.idl @@ -20,10 +20,6 @@ raw "#endif"; // TODO note that should be initialized to zero struct InitOptions { // TODO cbSize - - // If nonzero, allocations will be logged to stderr. - // See leaks.awk. - field debugLogAllocations int; }; func Init(options *InitOptions) *const char; diff --git a/uipriv.h b/uipriv.h index 3e560cd8..759bd629 100644 --- a/uipriv.h +++ b/uipriv.h @@ -3,6 +3,7 @@ extern uiInitOptions options; +// TODO remove the type name arguments extern void *uiAlloc(size_t, const char *); #define uiNew(T) ((T *) uiAlloc(sizeof (T), #T )) extern void *uiRealloc(void *, size_t, const char *); diff --git a/unix/alloc.c b/unix/alloc.c index 33482b25..2021feb4 100644 --- a/unix/alloc.c +++ b/unix/alloc.c @@ -7,8 +7,6 @@ void *uiAlloc(size_t size, const char *type) void *out; out = g_malloc0(size); - if (options.debugLogAllocations) - fprintf(stderr, "%p alloc %s\n", out, type); return out; } @@ -20,14 +18,10 @@ void *uiRealloc(void *p, size_t size, const char *type) return uiAlloc(size, type); // TODO fill with 0s out = g_realloc(p, size); - if (options.debugLogAllocations) - fprintf(stderr, "%p realloc %p\n", p, out); return out; } void uiFree(void *p) { g_free(p); - if (options.debugLogAllocations) - fprintf(stderr, "%p free\n", p); } diff --git a/unix/container.c b/unix/container.c index 6f4a500d..290f4aa5 100644 --- a/unix/container.c +++ b/unix/container.c @@ -27,8 +27,6 @@ G_DEFINE_TYPE(containerWidget, containerWidget, GTK_TYPE_CONTAINER) static void containerWidget_init(containerWidget *c) { - if (options.debugLogAllocations) - fprintf(stderr, "%p alloc containerWidget\n", c); c->widgets = g_ptr_array_new(); gtk_widget_set_has_window(GTK_WIDGET(c), FALSE); } @@ -44,8 +42,6 @@ static void containerWidget_finalize(GObject *obj) g_ptr_array_unref(c->widgets); G_OBJECT_CLASS(containerWidget_parent_class)->finalize(obj); - if (options.debugLogAllocations) - fprintf(stderr, "%p free\n", obj); } static void containerWidget_add(GtkContainer *container, GtkWidget *widget) diff --git a/windows/alloc.c b/windows/alloc.c index 147c90d2..51d535d6 100644 --- a/windows/alloc.c +++ b/windows/alloc.c @@ -17,8 +17,6 @@ void *uiAlloc(size_t size, const char *type) abort(); } ZeroMemory(out, size); - if (options.debugLogAllocations) - fprintf(stderr, "%p alloc %s\n", out, type); return out; } @@ -34,8 +32,6 @@ void *uiRealloc(void *p, size_t size, const char *type) abort(); } // TODO zero the extra memory - if (options.debugLogAllocations) - fprintf(stderr, "%p realloc %p\n", p, out); return out; } @@ -44,6 +40,4 @@ void uiFree(void *p) if (p == NULL) return; free(p); - if (options.debugLogAllocations) - fprintf(stderr, "%p free\n", p); }