Unified the allocators across all platforms so that everyone uses uiAlloc() and friends.
This commit is contained in:
parent
03d94db0fd
commit
7b1dfbf1d6
|
@ -0,0 +1,18 @@
|
|||
// 7 april 2015
|
||||
#include "uipriv_unix.h"
|
||||
|
||||
void *uiAlloc(size_t size)
|
||||
{
|
||||
return g_malloc0(size);
|
||||
}
|
||||
|
||||
void *uiRealloc(void *p, size_t size)
|
||||
{
|
||||
// TODO fill with 0s
|
||||
return g_realloc(p, size);
|
||||
}
|
||||
|
||||
void uiFree(void *p)
|
||||
{
|
||||
g_free(p);
|
||||
}
|
|
@ -26,7 +26,7 @@ uiControl *uiNewButton(const char *text)
|
|||
GParameter props[1];
|
||||
GtkWidget *widget;
|
||||
|
||||
b = g_new0(struct button, 1);
|
||||
b = uiNew(struct button);
|
||||
|
||||
props[0].name = "label";
|
||||
g_value_init(&(props[0].value), G_TYPE_STRING);
|
||||
|
|
|
@ -9,10 +9,10 @@ uiInitError *uiInit(uiInitOptions *o)
|
|||
{
|
||||
uiInitError *err;
|
||||
|
||||
err = g_new0(uiInitError, 1);
|
||||
err = uiNew(uiInitError);
|
||||
if (gtk_init_with_args(NULL, NULL, NULL, NULL, NULL, &(err->err)) == FALSE)
|
||||
return err;
|
||||
g_free(err);
|
||||
uiFree(err);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -24,5 +24,5 @@ const char *uiInitErrorMessage(uiInitError *err)
|
|||
void uiInitErrorFree(uiInitError *err)
|
||||
{
|
||||
g_error_free(err->err);
|
||||
g_free(err);
|
||||
uiFree(err);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ uiControl *uiUnixNewControl(GType type, guint nConstructParams, GParameter *cons
|
|||
{
|
||||
uiSingleWidgetControl *c;
|
||||
|
||||
c = g_new0(uiSingleWidgetControl, 1);
|
||||
c = uiNew(uiSingleWidgetControl);
|
||||
c->widget = GTK_WIDGET(g_object_newv(type, nConstructParams, constructParams));
|
||||
c->immediate = c->widget;
|
||||
|
||||
|
|
|
@ -18,3 +18,9 @@ struct uiControl {
|
|||
void (*containerShow)(uiControl *);
|
||||
void (*containerHide)(uiControl *);
|
||||
};
|
||||
|
||||
extern void *uiAlloc(size_t);
|
||||
// TODO use this in existing files
|
||||
#define uiNew(T) ((T *) uiAlloc(sizeof (T)))
|
||||
extern void *uiRealloc(void *, size_t);
|
||||
extern void uiFree(void *);
|
||||
|
|
|
@ -11,13 +11,6 @@
|
|||
struct uiSizing {
|
||||
};
|
||||
|
||||
// alloc_darwin.m
|
||||
extern void *uiAlloc(size_t);
|
||||
// TODO use this in existing files
|
||||
#define uiNew(T) ((T *) uiAlloc(sizeof (T)))
|
||||
extern void *uiRealloc(void *, size_t);
|
||||
extern void uiFree(void *);
|
||||
|
||||
// util_darwin.m
|
||||
extern void setStandardControlFont(NSControl *);
|
||||
|
||||
|
|
|
@ -42,13 +42,6 @@ struct uiSizing {
|
|||
LONG internalLeading;
|
||||
};
|
||||
|
||||
// alloc_windows.c
|
||||
extern void *uiAlloc(size_t);
|
||||
// TODO use this in existing files
|
||||
#define uiNew(T) ((T *) uiAlloc(sizeof (T)))
|
||||
extern void *uiRealloc(void *, size_t);
|
||||
extern void uiFree(void *);
|
||||
|
||||
// debug_windows.c
|
||||
extern HRESULT logLastError(const char *);
|
||||
extern HRESULT logHRESULT(const char *, HRESULT);
|
||||
|
|
|
@ -12,7 +12,7 @@ uiWindow *uiNewWindow(char *title, int width, int height)
|
|||
{
|
||||
uiWindow *w;
|
||||
|
||||
w = g_new0(uiWindow, 1);
|
||||
w = uiNew(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);
|
||||
|
@ -24,7 +24,7 @@ uiWindow *uiNewWindow(char *title, int width, int height)
|
|||
void uiWindowDestroy(uiWindow *w)
|
||||
{
|
||||
gtk_widget_destroy(w->widget);
|
||||
g_free(w);
|
||||
uiFree(w);
|
||||
}
|
||||
|
||||
uintptr_t uiWindowHandle(uiWindow *w)
|
||||
|
|
Loading…
Reference in New Issue