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