diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-10-26 00:54:20 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-10-26 00:54:20 +0000 |
commit | e9c25fd00ec34e0a7ca421b1ac230db157985f92 (patch) | |
tree | 132b185e0e6b7516285b9a084e5a1ee65c166889 | |
parent | 0bb6bfe0b08eb9fc2ba62f64bdb21cb5b592c292 (diff) | |
download | dimension-e9c25fd00ec34e0a7ca421b1ac230db157985f92.tar.xz |
Don't check if it's too late to add canvas optimizers.
This fixes some errors displayed by concurrency checkers like helgrind and drd.
-rw-r--r-- | libdimension/canvas.c | 14 | ||||
-rw-r--r-- | libdimension/dimension/canvas.h | 5 | ||||
-rw-r--r-- | libdimension/gl.c | 7 | ||||
-rw-r--r-- | libdimension/png.c | 6 |
4 files changed, 6 insertions, 26 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c index 9329a07..1d74a33 100644 --- a/libdimension/canvas.c +++ b/libdimension/canvas.c @@ -43,7 +43,6 @@ dmnsn_new_canvas(unsigned int x, unsigned int y) /* Allocate room for the optimizers */ canvas->optimizers = dmnsn_new_array(sizeof(dmnsn_canvas_optimizer)); - canvas->too_late = 0; } return canvas; @@ -73,16 +72,10 @@ dmnsn_delete_canvas(dmnsn_canvas *canvas) } /* Set a canvas optimizer */ -int +void dmnsn_optimize_canvas(dmnsn_canvas *canvas, dmnsn_canvas_optimizer optimizer) { - if (canvas->too_late) { - /* Don't set an optimizer if dmnsn_set_pixel() has been called */ - return 1; - } else { - dmnsn_array_push(canvas->optimizers, &optimizer); - return 0; - } + dmnsn_array_push(canvas->optimizers, &optimizer); } /* Set the color of a pixel */ @@ -93,9 +86,6 @@ dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y, unsigned int i; dmnsn_canvas_optimizer optimizer; - /* Don't allow any more optimizers */ - canvas->too_late = 1; - /* Set the pixel */ canvas->pixels[y*canvas->x + x] = color; diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h index 0d37acf..62b5b75 100644 --- a/libdimension/dimension/canvas.h +++ b/libdimension/dimension/canvas.h @@ -31,7 +31,6 @@ typedef struct { /* An array of dmnsn_canvas_optimizer's */ dmnsn_array *optimizers; - int too_late; /* Is it too late to add optimizers? */ /* * Stored in first-quadrant representation (origin is bottom-left). The pixel @@ -63,8 +62,8 @@ dmnsn_canvas *dmnsn_new_canvas(unsigned int x, unsigned int y); void dmnsn_delete_canvas(dmnsn_canvas *canvas); /* Set a canvas optimizer */ -int dmnsn_optimize_canvas(dmnsn_canvas *canvas, - dmnsn_canvas_optimizer optimizer); +void dmnsn_optimize_canvas(dmnsn_canvas *canvas, + dmnsn_canvas_optimizer optimizer); /* Pixel accessors */ diff --git a/libdimension/gl.c b/libdimension/gl.c index 31e0127..1bbf749 100644 --- a/libdimension/gl.c +++ b/libdimension/gl.c @@ -53,12 +53,7 @@ dmnsn_gl_optimize_canvas(dmnsn_canvas *canvas) } /* Set a new optimizer */ - if (dmnsn_optimize_canvas(canvas, optimizer) != 0) { - /* Set failed; dmnsn_set_pixel() has probably been called already */ - free(optimizer.ptr); - return 1; - } - + dmnsn_optimize_canvas(canvas, optimizer); return 0; } diff --git a/libdimension/png.c b/libdimension/png.c index 83eb38e..bc547a1 100644 --- a/libdimension/png.c +++ b/libdimension/png.c @@ -54,11 +54,7 @@ dmnsn_png_optimize_canvas(dmnsn_canvas *canvas) return 1; } - if (dmnsn_optimize_canvas(canvas, optimizer) != 0) { - free(optimizer.ptr); - return 1; - } - + dmnsn_optimize_canvas(canvas, optimizer); return 0; } |