Index: trunk/src/obj_pstk.h =================================================================== --- trunk/src/obj_pstk.h (revision 12927) +++ trunk/src/obj_pstk.h (revision 12928) @@ -102,8 +102,9 @@ /* free fields of a proto (not freeing the proto itself, not removing it from lists */ void pcb_pstk_proto_free_fields(pcb_pstk_proto_t *dst); -/* allocate the point array of a poly shape (single allocation for x and y) */ +/* allocate/free the point array of a poly shape (single allocation for x and y) */ void pcb_pstk_shape_alloc_poly(pcb_pstk_poly_t *poly, int len); +void pcb_pstk_shape_free_poly(pcb_pstk_poly_t *poly); /* geometry for select.c and search.c; if layer is NULL, consider all shapes */ int pcb_pstk_near_box(pcb_pstk_t *ps, pcb_box_t *box, pcb_layer_t *layer); @@ -135,6 +136,9 @@ void pcb_pstk_proto_copy(pcb_pstk_proto_t *dst, const pcb_pstk_proto_t *src); void pcb_pstk_shape_copy(pcb_pstk_shape_t *dst, pcb_pstk_shape_t *src); +/* free all fields of a shape */ +void pcb_pstk_shape_free(pcb_pstk_shape_t *s); + /* grow (or shrink) a prototype to or by val - change the proto in place */ void pcb_pstk_proto_grow(pcb_pstk_proto_t *proto, pcb_bool is_absolute, pcb_coord_t val); Index: trunk/src/obj_pstk_proto.c =================================================================== --- trunk/src/obj_pstk_proto.c (revision 12927) +++ trunk/src/obj_pstk_proto.c (revision 12928) @@ -52,6 +52,14 @@ poly->pa = NULL; } +void pcb_pstk_shape_free_poly(pcb_pstk_poly_t *poly) +{ + if (poly->pa != NULL) + pcb_polyarea_free(&poly->pa); + free(poly->x); + poly->len = 0; +} + void pcb_pstk_shape_copy_poly(pcb_pstk_poly_t *dst, const pcb_pstk_poly_t *src) { memcpy(dst->x, src->x, sizeof(src->x[0]) * src->len * 2); @@ -289,6 +297,17 @@ } } +void pcb_pstk_shape_free(pcb_pstk_shape_t *s) +{ + switch(s->shape) { + case PCB_PSSH_LINE: + case PCB_PSSH_CIRC: + break; /* no allocation */ + case PCB_PSSH_POLY: + pcb_pstk_shape_free_poly(&s->data.poly); + break; + } +} void pcb_pstk_tshape_copy(pcb_pstk_tshape_t *ts_dst, pcb_pstk_tshape_t *ts_src) {