uiAlloc() et al -> uiprivAlloc() et al, GTK+ code.
This commit is contained in:
parent
8ca32f098f
commit
099c4ff631
14
unix/alloc.c
14
unix/alloc.c
|
@ -43,7 +43,7 @@ void uninitAlloc(void)
|
|||
g_free(str);
|
||||
}
|
||||
|
||||
void *uiAlloc(size_t size, const char *type)
|
||||
void *uiprivAlloc(size_t size, const char *type)
|
||||
{
|
||||
void *out;
|
||||
|
||||
|
@ -54,13 +54,13 @@ void *uiAlloc(size_t size, const char *type)
|
|||
return DATA(out);
|
||||
}
|
||||
|
||||
void *uiRealloc(void *p, size_t new, const char *type)
|
||||
void *uiprivRealloc(void *p, size_t new, const char *type)
|
||||
{
|
||||
void *out;
|
||||
size_t *s;
|
||||
|
||||
if (p == NULL)
|
||||
return uiAlloc(new, type);
|
||||
return uiprivAlloc(new, type);
|
||||
p = BASE(p);
|
||||
out = g_realloc(p, EXTRA + new);
|
||||
s = SIZE(out);
|
||||
|
@ -68,17 +68,17 @@ void *uiRealloc(void *p, size_t new, const char *type)
|
|||
memset(((uint8_t *) DATA(out)) + *s, 0, new - *s);
|
||||
*s = new;
|
||||
if (g_ptr_array_remove(allocations, p) == FALSE)
|
||||
implbug("%p not found in allocations array in uiRealloc()", p);
|
||||
implbug("%p not found in allocations array in uiprivRealloc()", p);
|
||||
g_ptr_array_add(allocations, out);
|
||||
return DATA(out);
|
||||
}
|
||||
|
||||
void uiFree(void *p)
|
||||
void uiprivFree(void *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
implbug("attempt to uiFree(NULL)");
|
||||
implbug("attempt to uiprivFree(NULL)");
|
||||
p = BASE(p);
|
||||
g_free(p);
|
||||
if (g_ptr_array_remove(allocations, p) == FALSE)
|
||||
implbug("%p not found in allocations array in uiFree()", p);
|
||||
implbug("%p not found in allocations array in uiprivFree()", p);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parent
|
|||
if (child == NULL)
|
||||
return NULL;
|
||||
|
||||
c = uiNew(struct child);
|
||||
c = uiprivNew(struct child);
|
||||
c->c = child;
|
||||
c->widget = GTK_WIDGET(uiControlHandle(c->c));
|
||||
|
||||
|
@ -82,7 +82,7 @@ void childRemove(struct child *c)
|
|||
if (c->box != NULL)
|
||||
gtk_widget_destroy(c->box);
|
||||
|
||||
uiFree(c);
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
||||
void childDestroy(struct child *c)
|
||||
|
|
|
@ -6,7 +6,7 @@ uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style)
|
|||
{
|
||||
uiDrawContext *c;
|
||||
|
||||
c = uiNew(uiDrawContext);
|
||||
c = uiprivNew(uiDrawContext);
|
||||
c->cr = cr;
|
||||
c->style = style;
|
||||
return c;
|
||||
|
@ -15,7 +15,7 @@ uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style)
|
|||
void freeContext(uiDrawContext *c)
|
||||
{
|
||||
// free neither cr nor style; we own neither
|
||||
uiFree(c);
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
||||
static cairo_pattern_t *mkbrush(uiDrawBrush *b)
|
||||
|
|
|
@ -28,7 +28,7 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode mode)
|
|||
{
|
||||
uiDrawPath *p;
|
||||
|
||||
p = uiNew(uiDrawPath);
|
||||
p = uiprivNew(uiDrawPath);
|
||||
p->pieces = g_array_new(FALSE, TRUE, sizeof (struct piece));
|
||||
p->fillMode = mode;
|
||||
return p;
|
||||
|
@ -37,7 +37,7 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode mode)
|
|||
void uiDrawFreePath(uiDrawPath *p)
|
||||
{
|
||||
g_array_free(p->pieces, TRUE);
|
||||
uiFree(p);
|
||||
uiprivFree(p);
|
||||
}
|
||||
|
||||
static void add(uiDrawPath *p, struct piece *piece)
|
||||
|
|
|
@ -16,11 +16,11 @@ struct graphemes *uiprivNewGraphemes(void *s, size_t len)
|
|||
size_t i;
|
||||
size_t *op;
|
||||
|
||||
g = uiNew(struct graphemes);
|
||||
g = uiprivNew(struct graphemes);
|
||||
|
||||
// TODO see if we can use the utf routines
|
||||
lenchars = g_utf8_strlen(text, -1);
|
||||
logattrs = (PangoLogAttr *) uiAlloc((lenchars + 1) * sizeof (PangoLogAttr), "PangoLogAttr[] (graphemes)");
|
||||
logattrs = (PangoLogAttr *) uiprivAlloc((lenchars + 1) * sizeof (PangoLogAttr), "PangoLogAttr[] (graphemes)");
|
||||
pango_get_log_attrs(text, len,
|
||||
-1, NULL,
|
||||
logattrs, lenchars + 1);
|
||||
|
@ -31,8 +31,8 @@ struct graphemes *uiprivNewGraphemes(void *s, size_t len)
|
|||
if (logattrs[i].is_cursor_position != 0)
|
||||
g->len++;
|
||||
|
||||
g->pointsToGraphemes = (size_t *) uiAlloc((len + 1) * sizeof (size_t), "size_t[] (graphemes)");
|
||||
g->graphemesToPoints = (size_t *) uiAlloc((g->len + 1) * sizeof (size_t), "size_t[] (graphemes)");
|
||||
g->pointsToGraphemes = (size_t *) uiprivAlloc((len + 1) * sizeof (size_t), "size_t[] (graphemes)");
|
||||
g->graphemesToPoints = (size_t *) uiprivAlloc((g->len + 1) * sizeof (size_t), "size_t[] (graphemes)");
|
||||
|
||||
// compute the graphemesToPoints array
|
||||
// TODO merge with the next for loop somehow?
|
||||
|
@ -58,6 +58,6 @@ struct graphemes *uiprivNewGraphemes(void *s, size_t len)
|
|||
// and do the last one
|
||||
*op++ = i;
|
||||
|
||||
uiFree(logattrs);
|
||||
uiprivFree(logattrs);
|
||||
return g;
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ static void freeImageRep(gpointer item)
|
|||
|
||||
buf = cairo_image_surface_get_data(cs);
|
||||
cairo_surface_destroy(cs);
|
||||
uiFree(buf);
|
||||
uiprivFree(buf);
|
||||
}
|
||||
|
||||
uiImage *uiNewImage(double width, double height)
|
||||
{
|
||||
uiImage *i;
|
||||
|
||||
i = uiNew(uiImage);
|
||||
i = uiprivNew(uiImage);
|
||||
i->width = width;
|
||||
i->height = height;
|
||||
i->images = g_ptr_array_new_with_free_func(freeImageRep);
|
||||
|
@ -31,7 +31,7 @@ uiImage *uiNewImage(double width, double height)
|
|||
void uiFreeImage(uiImage *i)
|
||||
{
|
||||
g_ptr_array_free(i->images, TRUE);
|
||||
uiFree(i);
|
||||
uiprivFree(i);
|
||||
}
|
||||
|
||||
void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int pixelStride)
|
||||
|
@ -43,7 +43,7 @@ void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, in
|
|||
int y;
|
||||
|
||||
cstride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, pixelWidth);
|
||||
buf = (unsigned char *) uiAlloc((cstride * pixelHeight * 4) * sizeof (unsigned char), "unsigned char[]");
|
||||
buf = (unsigned char *) uiprivAlloc((cstride * pixelHeight * 4) * sizeof (unsigned char), "unsigned char[]");
|
||||
p = buf;
|
||||
for (y = 0; y < pixelStride * pixelHeight; y += pixelStride) {
|
||||
memmove(p, src + y, cstride);
|
||||
|
|
|
@ -99,7 +99,7 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
|||
{
|
||||
struct queued *q;
|
||||
|
||||
// we have to use g_new0()/g_free() because uiAlloc() is only safe to call on the main thread
|
||||
// we have to use g_new0()/g_free() because uiprivAlloc() is only safe to call on the main thread
|
||||
// for some reason it didn't affect me, but it did affect krakjoe
|
||||
q = g_new0(struct queued, 1);
|
||||
q->f = f;
|
||||
|
|
12
unix/menu.c
12
unix/menu.c
|
@ -137,7 +137,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
if (menusFinalized)
|
||||
userbug("You cannot create a new menu item after menus have been finalized.");
|
||||
|
||||
item = uiNew(uiMenuItem);
|
||||
item = uiprivNew(uiMenuItem);
|
||||
|
||||
g_array_append_val(m->items, item);
|
||||
|
||||
|
@ -234,7 +234,7 @@ uiMenu *uiNewMenu(const char *name)
|
|||
if (menus == NULL)
|
||||
menus = g_array_new(FALSE, TRUE, sizeof (uiMenu *));
|
||||
|
||||
m = uiNew(uiMenu);
|
||||
m = uiprivNew(uiMenu);
|
||||
|
||||
g_array_append_val(menus, m);
|
||||
|
||||
|
@ -260,7 +260,7 @@ static void appendMenuItem(GtkMenuShell *submenu, uiMenuItem *item, uiWindow *w)
|
|||
singleSetChecked(GTK_CHECK_MENU_ITEM(menuitem), item->checked, signal);
|
||||
}
|
||||
gtk_menu_shell_append(submenu, menuitem);
|
||||
ww = uiNew(struct menuItemWindow);
|
||||
ww = uiprivNew(struct menuItemWindow);
|
||||
ww->w = w;
|
||||
ww->signal = signal;
|
||||
g_hash_table_insert(item->windows, menuitem, ww);
|
||||
|
@ -309,7 +309,7 @@ static void freeMenuItem(GtkWidget *widget, gpointer data)
|
|||
w = (struct menuItemWindow *) g_hash_table_lookup(item->windows, widget);
|
||||
if (g_hash_table_remove(item->windows, widget) == FALSE)
|
||||
implbug("GtkMenuItem %p not in menu item's item/window map", widget);
|
||||
uiFree(w);
|
||||
uiprivFree(w);
|
||||
fmi->i++;
|
||||
}
|
||||
|
||||
|
@ -357,10 +357,10 @@ void uninitMenus(void)
|
|||
implbug("menu item %p (%s) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||
g_free(item->name);
|
||||
g_hash_table_destroy(item->windows);
|
||||
uiFree(item);
|
||||
uiprivFree(item);
|
||||
}
|
||||
g_array_free(m->items, TRUE);
|
||||
uiFree(m);
|
||||
uiprivFree(m);
|
||||
}
|
||||
g_array_free(menus, TRUE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue