From 83b552b622da561de047f798e5d50d59f724b1eb Mon Sep 17 00:00:00 2001 From: Julian T Date: Mon, 23 Mar 2020 16:55:45 +0100 Subject: No dynamic allocation --- pgm.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'pgm.c') diff --git a/pgm.c b/pgm.c index b3f233f..eb0c101 100644 --- a/pgm.c +++ b/pgm.c @@ -17,10 +17,6 @@ int pgm_write_pixel(FILE *fp, color_t *c) color_t *color_set(color_t *c, COORD_T r, COORD_T g, COORD_T b) { - if (!c) { - c = (color_t *) malloc(sizeof(color_t)); - } - c->r = r; c->g = g; c->b = b; @@ -30,10 +26,6 @@ color_t *color_set(color_t *c, COORD_T r, COORD_T g, COORD_T b) color_t *color_add(color_t *dest, color_t *a, color_t *b) { - if (!dest) { - dest = (color_t *) malloc(sizeof(color_t)); - } - COORD_T tmp = a->r + b->r; dest->r = tmp > 1 ? 1 : tmp; @@ -48,10 +40,6 @@ color_t *color_add(color_t *dest, color_t *a, color_t *b) color_t *color_scale(color_t *dest, color_t *a, COORD_T b) { - if (!dest) { - dest = (color_t *) malloc(sizeof(color_t)); - } - COORD_T tmp = a->r * b; dest->r = tmp > 1 ? 1 : tmp; @@ -66,10 +54,6 @@ color_t *color_scale(color_t *dest, color_t *a, COORD_T b) color_t *color_scale_vector(color_t *dest, color_t *a, vector_t *v) { - if (!dest) { - dest = (color_t *) malloc(sizeof(color_t)); - } - dest->r = a->r * v->x; dest->g = a->g * v->y; dest->b = a->b * v->z; -- cgit v1.2.3