diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-05 20:09:38 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-05 22:47:44 -0600 |
commit | 6c2943e735c99579b5b861f67f2d98e5ddd6306f (patch) | |
tree | e882a1dda2726dd9dfca3fe2dd44750b17b1edda /libdimension/canvas.c | |
parent | b14506e501770aeaf54d1160c0073398cc29a038 (diff) | |
download | dimension-6c2943e735c99579b5b861f67f2d98e5ddd6306f.tar.xz |
Use C99 for loop initializers.
Diffstat (limited to 'libdimension/canvas.c')
-rw-r--r-- | libdimension/canvas.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c index db51cda..4ed7fd5 100644 --- a/libdimension/canvas.c +++ b/libdimension/canvas.c @@ -24,7 +24,7 @@ /* Allocate a new canvas, of width x and height y */ dmnsn_canvas * -dmnsn_new_canvas(unsigned int x, unsigned int y) +dmnsn_new_canvas(size_t x, size_t y) { /* Allocate the dmnsn_canvas struct */ dmnsn_canvas *canvas = dmnsn_malloc(sizeof(dmnsn_canvas)); @@ -46,12 +46,10 @@ dmnsn_new_canvas(unsigned int x, unsigned int y) void dmnsn_delete_canvas(dmnsn_canvas *canvas) { - unsigned int i; - dmnsn_canvas_optimizer optimizer; - if (canvas) { /* Free the optimizers */ - for (i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) { + for (size_t i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) { + dmnsn_canvas_optimizer optimizer; dmnsn_array_get(canvas->optimizers, i, &optimizer); if (optimizer.free_fn) { (*optimizer.free_fn)(optimizer.ptr); @@ -74,17 +72,16 @@ dmnsn_optimize_canvas(dmnsn_canvas *canvas, dmnsn_canvas_optimizer optimizer) /* Set the color of a pixel */ void -dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y, +dmnsn_set_pixel(dmnsn_canvas *canvas, size_t x, size_t y, dmnsn_color color) { - unsigned int i; dmnsn_canvas_optimizer optimizer; /* Set the pixel */ canvas->pixels[y*canvas->x + x] = color; /* Call the optimizers */ - for (i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) { + for (size_t i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) { dmnsn_array_get(canvas->optimizers, i, &optimizer); (*optimizer.optimizer_fn)(canvas, optimizer, x, y); } @@ -94,10 +91,8 @@ dmnsn_set_pixel(dmnsn_canvas *canvas, unsigned int x, unsigned int y, void dmnsn_clear_canvas(dmnsn_canvas *canvas, dmnsn_color color) { - unsigned int x; - for (x = 0; x < canvas->x; ++x) { - unsigned int y; - for (y = 0; y < canvas->y; ++y) { + for (size_t x = 0; x < canvas->x; ++x) { + for (size_t y = 0; y < canvas->y; ++y) { dmnsn_set_pixel(canvas, x, y, color); } } |