7
static void *zmalloc(Vmalloc_t *arena, size_t request)
11
rv = vmalloc(arena, request);
12
if (rv) memset(rv, request, '\0');
16
ilcurve_t *il_newcurve(Vmalloc_t *arena, ilcurvetype_t kind, int maxpts) {
19
rv = zmalloc(arena,sizeof(ilcurve_t));
22
rv->p = zmalloc(arena,sizeof(ilcoord_t)*maxpts);
26
/* note that the value of contents is copied and contents is freed */
27
ilshape_t *il_newshape(Vmalloc_t *arena, ilcurve_t *contents, ilshape_t *link) {
30
rv = zmalloc(arena, sizeof(ilshape_t));
32
if (contents->type == IL_POLYLINE)
33
rv->type = IL_POLYGON;
35
rv->type = IL_SPLINEGON;
36
rv->def.curve = *contents;
37
/* i designed the interface wrong. either def.curve should
38
be a pointer, or the contents arg should be a value not a
39
pointer, but this is the easiest way to deal with the error
41
vmfree(vmregion(contents),contents);
43
else rv->type = IL_NOSHAPE;
48
void il_freeshape(Vmalloc_t *arena, ilshape_t *shape)
58
if (shape->def.curve.p)
59
vmfree(arena,shape->def.curve.p);
69
void il_freecurve(Vmalloc_t *arena, ilcurve_t *curve)
71
vmfree(arena,curve->p);
75
ilshape_t *il_copyshape(Vmalloc_t *arena, ilshape_t *src)
80
rv = zmalloc(arena,sizeof(ilshape_t));
85
rv->def.curve.type = src->def.curve.type;
86
rv->def.curve.n = src->def.curve.n;
87
sz = rv->def.curve.n * sizeof(ilcoord_t);
88
rv->def.curve.p = zmalloc(arena,sz);
89
memcpy(rv->def.curve.p,src->def.curve.p,sz);
93
rv->def.ellipse = src->def.ellipse;