// Build tree top down, assigning to older objects. static void Populate(int iDepth, Node thisNode) { if (iDepth<=0) { return; } else { iDepth--; # ifdef GC thisNode->left = GC_NEW(Node0); HOLE(); thisNode->right = GC_NEW(Node0); HOLE(); # else thisNode->left = calloc(1, sizeof(Node0)); thisNode->right = calloc(1, sizeof(Node0)); # endif Populate (iDepth, thisNode->left); Populate (iDepth, thisNode->right); } }
/* Function: al_draw_polygon_with_holes */ void al_draw_polygon_with_holes(const float *vertices, int vertex_count, const int *holes, int hole_count, ALLEGRO_LINE_JOIN join_style, ALLEGRO_COLOR color, float thickness, float miter_limit) { # define VERTEX(index) ((const float*)(((uint8_t*)vertices) + (sizeof(float) * 2) * ((vertex_count + (index)) % vertex_count))) # define HOLE(index) (*((int*)(((uint8_t*)holes) + sizeof(int) * ((hole_count + index) % hole_count)))) int i; if (hole_count <= 0) return; al_draw_polyline(vertices, HOLE(0), join_style, ALLEGRO_LINE_CAP_CLOSED, color, thickness, miter_limit); for (i = 1; i < hole_count; ++i) al_draw_polyline_ex(VERTEX(HOLE(i) - 1), -(int)(sizeof(float) * 2), HOLE(i) - HOLE(i - 1), join_style, ALLEGRO_LINE_CAP_CLOSED, color, thickness, miter_limit); # undef VERTEX # undef HOLE }
// Build tree bottom-up static Node MakeTree(int iDepth) { Node result; if (iDepth<=0) { # ifndef GC result = calloc(1, sizeof(Node0)); # else result = GC_NEW(Node0); HOLE(); # endif /* result is implicitly initialized in both cases. */ return result; } else { Node left = MakeTree(iDepth-1); Node right = MakeTree(iDepth-1); # ifndef GC result = malloc(sizeof(Node0)); # else result = GC_NEW(Node0); HOLE(); # endif init_Node(result, left, right); return result; } }