/* * p2d_free.c - Deallocate polygons * * Written 2012 by Werner Almesberger * Copyright 2012 Werner Almesberger * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. */ #include #include "poly2d.h" void p2d_free(struct p2d *p) { struct v2d *v, *next; v = p->v; while (v) { next = v->next; free(v); v = next; if (v == p->v) break; } free(p); } void p2d_free_all(struct p2d *p) { struct p2d *next; while (p) { next = p->next; p2d_free(p); p = next; } }