uiAlloc() et al -> uiprivAlloc() et al, OS X code.
This commit is contained in:
parent
72e8b9a198
commit
8ca32f098f
|
@ -41,7 +41,7 @@ void uninitAlloc(void)
|
|||
[str release];
|
||||
}
|
||||
|
||||
void *uiAlloc(size_t size, const char *type)
|
||||
void *uiprivAlloc(size_t size, const char *type)
|
||||
{
|
||||
void *out;
|
||||
|
||||
|
@ -57,17 +57,17 @@ 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 = realloc(p, EXTRA + new);
|
||||
if (out == NULL) {
|
||||
fprintf(stderr, "memory exhausted in uiRealloc()\n");
|
||||
fprintf(stderr, "memory exhausted in uiprivRealloc()\n");
|
||||
abort();
|
||||
}
|
||||
s = SIZE(out);
|
||||
|
@ -79,10 +79,10 @@ void *uiRealloc(void *p, size_t new, const char *type)
|
|||
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);
|
||||
free(p);
|
||||
[allocations removeObject:[NSValue valueWithPointer:p]];
|
||||
|
|
|
@ -12,7 +12,7 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode mode)
|
|||
{
|
||||
uiDrawPath *p;
|
||||
|
||||
p = uiNew(uiDrawPath);
|
||||
p = uiprivNew(uiDrawPath);
|
||||
p->path = CGPathCreateMutable();
|
||||
p->fillMode = mode;
|
||||
return p;
|
||||
|
@ -21,7 +21,7 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode mode)
|
|||
void uiDrawFreePath(uiDrawPath *p)
|
||||
{
|
||||
CGPathRelease((CGPathRef) (p->path));
|
||||
uiFree(p);
|
||||
uiprivFree(p);
|
||||
}
|
||||
|
||||
void uiDrawPathNewFigure(uiDrawPath *p, double x, double y)
|
||||
|
@ -108,7 +108,7 @@ uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
|||
{
|
||||
uiDrawContext *c;
|
||||
|
||||
c = uiNew(uiDrawContext);
|
||||
c = uiprivNew(uiDrawContext);
|
||||
c->c = ctxt;
|
||||
c->height = height;
|
||||
return c;
|
||||
|
@ -116,7 +116,7 @@ uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
|||
|
||||
void freeContext(uiDrawContext *c)
|
||||
{
|
||||
uiFree(c);
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
||||
// a stroke is identical to a fill of a stroked path
|
||||
|
@ -160,7 +160,7 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro
|
|||
// create a temporary path identical to the previous one
|
||||
dashPath = (CGPathRef) path->path;
|
||||
if (p->NumDashes != 0) {
|
||||
dashes = (CGFloat *) uiAlloc(p->NumDashes * sizeof (CGFloat), "CGFloat[]");
|
||||
dashes = (CGFloat *) uiprivAlloc(p->NumDashes * sizeof (CGFloat), "CGFloat[]");
|
||||
for (i = 0; i < p->NumDashes; i++)
|
||||
dashes[i] = p->Dashes[i];
|
||||
dashPath = CGPathCreateCopyByDashingPath(path->path,
|
||||
|
@ -168,7 +168,7 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro
|
|||
p->DashPhase,
|
||||
dashes,
|
||||
p->NumDashes);
|
||||
uiFree(dashes);
|
||||
uiprivFree(dashes);
|
||||
}
|
||||
// the documentation is wrong: this produces a path suitable for calling CGPathCreateCopyByStrokingPath(), not for filling directly
|
||||
// the cast is safe; we never modify the CGPathRef and always cast it back to a CGPathRef anyway
|
||||
|
@ -224,8 +224,8 @@ static void fillGradient(CGContextRef ctxt, uiDrawPath *p, uiDrawBrush *b)
|
|||
// TODO add NULL check to other uses of CGColorSpace
|
||||
|
||||
// make the gradient
|
||||
colors = uiAlloc(b->NumStops * 4 * sizeof (CGFloat), "CGFloat[]");
|
||||
locations = uiAlloc(b->NumStops * sizeof (CGFloat), "CGFloat[]");
|
||||
colors = uiprivAlloc(b->NumStops * 4 * sizeof (CGFloat), "CGFloat[]");
|
||||
locations = uiprivAlloc(b->NumStops * sizeof (CGFloat), "CGFloat[]");
|
||||
for (i = 0; i < b->NumStops; i++) {
|
||||
colors[i * 4 + 0] = b->Stops[i].R;
|
||||
colors[i * 4 + 1] = b->Stops[i].G;
|
||||
|
@ -234,8 +234,8 @@ static void fillGradient(CGContextRef ctxt, uiDrawPath *p, uiDrawBrush *b)
|
|||
locations[i] = b->Stops[i].Pos;
|
||||
}
|
||||
gradient = CGGradientCreateWithColorComponents(colorspace, colors, locations, b->NumStops);
|
||||
uiFree(locations);
|
||||
uiFree(colors);
|
||||
uiprivFree(locations);
|
||||
uiprivFree(colors);
|
||||
|
||||
// because we're mucking with clipping, we need to save the graphics state and restore it later
|
||||
CGContextSaveGState(ctxt);
|
||||
|
|
|
@ -365,7 +365,7 @@ static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiFontDescrip
|
|||
if ([d variation] != NULL)
|
||||
axisDict = uiprivMakeVariationAxisDict([d variationAxes], [d table:kCTFontTableAvar]);
|
||||
|
||||
closeness = (struct closeness *) uiAlloc(n * sizeof (struct closeness), "struct closeness[]");
|
||||
closeness = (struct closeness *) uiprivAlloc(n * sizeof (struct closeness), "struct closeness[]");
|
||||
for (i = 0; i < n; i++) {
|
||||
uiFontDescriptor fields;
|
||||
|
||||
|
@ -409,7 +409,7 @@ static CTFontDescriptorRef matchStyle(CTFontDescriptorRef against, uiFontDescrip
|
|||
// release everything
|
||||
if (axisDict != nil)
|
||||
[axisDict release];
|
||||
uiFree(closeness);
|
||||
uiprivFree(closeness);
|
||||
CFRelease(matching);
|
||||
// and release the original descriptor since we no longer need it
|
||||
CFRelease(against);
|
||||
|
|
|
@ -187,7 +187,7 @@ static fixed1616 *avarExtract(CFDataRef table, CFIndex index, size_t *n)
|
|||
}
|
||||
nEntries = nextuint16be();
|
||||
*n = nEntries * 2;
|
||||
entries = (fixed1616 *) uiAlloc(*n * sizeof (fixed1616), "fixed1616[]");
|
||||
entries = (fixed1616 *) uiprivAlloc(*n * sizeof (fixed1616), "fixed1616[]");
|
||||
p = entries;
|
||||
for (i = 0; i < *n; i++) {
|
||||
*p++ = fixed214ToFixed1616((fixed214) nextuint16be());
|
||||
|
@ -247,7 +247,7 @@ fail:
|
|||
- (void)dealloc
|
||||
{
|
||||
if (self->avarMappings != NULL) {
|
||||
uiFree(self->avarMappings);
|
||||
uiprivFree(self->avarMappings);
|
||||
self->avarMappings = NULL;
|
||||
}
|
||||
[super dealloc];
|
||||
|
|
|
@ -288,11 +288,11 @@ struct uiGrid {
|
|||
// now build a topological map of the grid gg[y][x]
|
||||
// also figure out which cells contain spanned views so they can be ignored later
|
||||
// treat hidden controls by keeping the indices -1
|
||||
gg = (int **) uiAlloc(ycount * sizeof (int *), "int[][]");
|
||||
gspan = (BOOL **) uiAlloc(ycount * sizeof (BOOL *), "BOOL[][]");
|
||||
gg = (int **) uiprivAlloc(ycount * sizeof (int *), "int[][]");
|
||||
gspan = (BOOL **) uiprivAlloc(ycount * sizeof (BOOL *), "BOOL[][]");
|
||||
for (y = 0; y < ycount; y++) {
|
||||
gg[y] = (int *) uiAlloc(xcount * sizeof (int), "int[]");
|
||||
gspan[y] = (BOOL *) uiAlloc(xcount * sizeof (BOOL), "BOOL[]");
|
||||
gg[y] = (int *) uiprivAlloc(xcount * sizeof (int), "int[]");
|
||||
gspan[y] = (BOOL *) uiprivAlloc(xcount * sizeof (BOOL), "BOOL[]");
|
||||
for (x = 0; x < xcount; x++)
|
||||
gg[y][x] = -1; // empty
|
||||
}
|
||||
|
@ -344,9 +344,9 @@ struct uiGrid {
|
|||
|
||||
// now build a topological map of the grid's views gv[y][x]
|
||||
// for any empty cell, create a dummy view
|
||||
gv = (NSView ***) uiAlloc(ycount * sizeof (NSView **), "NSView *[][]");
|
||||
gv = (NSView ***) uiprivAlloc(ycount * sizeof (NSView **), "NSView *[][]");
|
||||
for (y = 0; y < ycount; y++) {
|
||||
gv[y] = (NSView **) uiAlloc(xcount * sizeof (NSView *), "NSView *[]");
|
||||
gv[y] = (NSView **) uiprivAlloc(xcount * sizeof (NSView *), "NSView *[]");
|
||||
for (x = 0; x < xcount; x++)
|
||||
if (gg[y][x] == -1) {
|
||||
gv[y][x] = [[NSView alloc] initWithFrame:NSZeroRect];
|
||||
|
@ -360,8 +360,8 @@ struct uiGrid {
|
|||
}
|
||||
|
||||
// now figure out which rows and columns really expand
|
||||
hexpand = (BOOL *) uiAlloc(xcount * sizeof (BOOL), "BOOL[]");
|
||||
vexpand = (BOOL *) uiAlloc(ycount * sizeof (BOOL), "BOOL[]");
|
||||
hexpand = (BOOL *) uiprivAlloc(xcount * sizeof (BOOL), "BOOL[]");
|
||||
vexpand = (BOOL *) uiprivAlloc(ycount * sizeof (BOOL), "BOOL[]");
|
||||
// first, which don't span
|
||||
for (gc in self->children) {
|
||||
if (!uiControlVisible(gc.c))
|
||||
|
@ -522,16 +522,16 @@ struct uiGrid {
|
|||
// TODO make all expanding rows/columns the same height/width
|
||||
|
||||
// and finally clean up
|
||||
uiFree(hexpand);
|
||||
uiFree(vexpand);
|
||||
uiprivFree(hexpand);
|
||||
uiprivFree(vexpand);
|
||||
for (y = 0; y < ycount; y++) {
|
||||
uiFree(gg[y]);
|
||||
uiFree(gv[y]);
|
||||
uiFree(gspan[y]);
|
||||
uiprivFree(gg[y]);
|
||||
uiprivFree(gv[y]);
|
||||
uiprivFree(gspan[y]);
|
||||
}
|
||||
uiFree(gg);
|
||||
uiFree(gv);
|
||||
uiFree(gspan);
|
||||
uiprivFree(gg);
|
||||
uiprivFree(gv);
|
||||
uiprivFree(gspan);
|
||||
}
|
||||
|
||||
- (void)append:(gridChild *)gc
|
||||
|
|
|
@ -11,23 +11,23 @@ uiImage *uiNewImage(double width, double height)
|
|||
{
|
||||
uiImage *i;
|
||||
|
||||
i = uiNew(uiImage);
|
||||
i = uiprivNew(uiImage);
|
||||
i->size = NSMakeSize(width, height);
|
||||
i->i = [[NSImage alloc] initWithSize:i->size];
|
||||
i->swizzled = [NSMutableArray new];
|
||||
return i;
|
||||
}
|
||||
|
||||
void uiFreeImage(uiImage *i)
|
||||
void Image(uiImage *i)
|
||||
{
|
||||
NSValue *v;
|
||||
|
||||
[i->i release];
|
||||
// to be safe, do this after releasing the image
|
||||
for (v in i->swizzled)
|
||||
uiFree([v pointerValue]);
|
||||
uiprivFree([v pointerValue]);
|
||||
[i->swizzled release];
|
||||
uiFree(i);
|
||||
uiprivFree(i);
|
||||
}
|
||||
|
||||
void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int pixelStride)
|
||||
|
@ -40,7 +40,7 @@ void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, in
|
|||
// OS X demands that R and B are in the opposite order from what we expect
|
||||
// we must swizzle :(
|
||||
// LONGTERM test on a big-endian system
|
||||
swizzled = (uint8_t *) uiAlloc((pixelStride * pixelHeight * 4) * sizeof (uint8_t), "uint8_t[]");
|
||||
swizzled = (uint8_t *) uiprivAlloc((pixelStride * pixelHeight * 4) * sizeof (uint8_t), "uint8_t[]");
|
||||
bp = (uint8_t *) pixels;
|
||||
sp = swizzled;
|
||||
for (y = 0; y < pixelHeight * pixelStride; y += pixelStride)
|
||||
|
|
|
@ -12,7 +12,7 @@ struct mapTable *newMap(void)
|
|||
{
|
||||
struct mapTable *m;
|
||||
|
||||
m = uiNew(struct mapTable);
|
||||
m = uiprivNew(struct mapTable);
|
||||
m->m = [[NSMapTable alloc] initWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||
capacity:0];
|
||||
|
@ -24,7 +24,7 @@ void mapDestroy(struct mapTable *m)
|
|||
if ([m->m count] != 0)
|
||||
implbug("attempt to destroy map with items inside");
|
||||
[m->m release];
|
||||
uiFree(m);
|
||||
uiprivFree(m);
|
||||
}
|
||||
|
||||
void *mapGet(struct mapTable *m, void *key)
|
||||
|
|
|
@ -241,7 +241,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
if (menusFinalized)
|
||||
userbug("You can't create a new menu item after menus have been finalized.");
|
||||
|
||||
item = uiNew(uiMenuItem);
|
||||
item = uiprivNew(uiMenuItem);
|
||||
|
||||
item->type = type;
|
||||
switch (item->type) {
|
||||
|
@ -319,7 +319,7 @@ uiMenu *uiNewMenu(const char *name)
|
|||
if (menus == nil)
|
||||
menus = [NSMutableArray new];
|
||||
|
||||
m = uiNew(uiMenu);
|
||||
m = uiprivNew(uiMenu);
|
||||
|
||||
m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
||||
// use automatic menu item enabling for all menus for consistency's sake
|
||||
|
@ -359,10 +359,10 @@ void uninitMenus(void)
|
|||
|
||||
v = (NSValue *) obj;
|
||||
mi = (uiMenuItem *) [v pointerValue];
|
||||
uiFree(mi);
|
||||
uiprivFree(mi);
|
||||
}];
|
||||
[m->items release];
|
||||
uiFree(m);
|
||||
uiprivFree(m);
|
||||
}];
|
||||
[menus release];
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewDa
|
|||
[sv setAllowsMagnification:NO];
|
||||
|
||||
[sv setDocumentView:p->DocumentView];
|
||||
d = uiNew(struct scrollViewData);
|
||||
d = uiprivNew(struct scrollViewData);
|
||||
scrollViewSetScrolling(sv, d, p->HScroll, p->VScroll);
|
||||
|
||||
*dout = d;
|
||||
|
@ -57,5 +57,5 @@ void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hsc
|
|||
|
||||
void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d)
|
||||
{
|
||||
uiFree(d);
|
||||
uiprivFree(d);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue