X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fspline.c;h=d2d447771ae6a98469b18b6a3af6161f83a4ec81;hb=50be9bb40dc60130c99ffa568e6677779904ff70;hp=84de1cb47eb7581e56ed834aa77ea415eef9107a;hpb=f3e0240915ed9f9b3a61781f5c7002d587563fe0;p=xscreensaver diff --git a/utils/spline.c b/utils/spline.c index 84de1cb4..d2d44777 100644 --- a/utils/spline.c +++ b/utils/spline.c @@ -29,7 +29,6 @@ #define SMOOTHNESS 1.0 -static void no_more_memory (void); static void grow_spline_points (spline* s); static void mid_point (double x0, double y0, double x1, double y1, double *mx, double *my); @@ -45,19 +44,11 @@ static void calc_section (spline* s, double cminus1x, double cminus1y, double cx, double cy, double cplus1x, double cplus1y, double cplus2x, double cplus2y); -static void -no_more_memory (void) -{ - fprintf (stderr, "No more memory\n"); - exit (1); -} - spline* -make_spline (u_int size) +make_spline (unsigned int size) { spline* s = (spline*)calloc (1, sizeof (spline)); - if (!s) - no_more_memory (); + if (!s) abort(); s->n_controls = size; s->control_x = (double*)calloc (s->n_controls, sizeof (double)); s->control_y = (double*)calloc (s->n_controls, sizeof (double)); @@ -67,7 +58,7 @@ make_spline (u_int size) s->points = (XPoint*)calloc (s->allocated_points, sizeof (XPoint)); if (!s->control_x || !s->control_y || !s->points) - no_more_memory (); + abort(); return s; } @@ -78,9 +69,7 @@ grow_spline_points (spline *s) s->allocated_points *= 2; s->points = (XPoint*)realloc (s->points, s->allocated_points * sizeof (XPoint)); - - if (!s->points) - no_more_memory (); + if (!s->points) abort(); } static void @@ -319,3 +308,12 @@ spline_bounding_box (spline *s, XRectangle *rectangle_out) rectangle_out->width = max_x - min_x; rectangle_out->height = max_y - min_y; } + +void +free_spline(spline * s) +{ + free ((void *) s->control_x); + free ((void *) s->control_y); + free ((void *) s->points); + free ((void *) s); +}