summaryrefslogtreecommitdiffstats
path: root/libdimension/canvas.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-06-26 15:31:34 +0000
committerTavian Barnes <tavianator@gmail.com>2009-06-26 15:31:34 +0000
commit3ee98f3bac24fd1c70a9de3e0fbe774e762c25b3 (patch)
treeddc8d088662a88101670150c491012427c85b5bf /libdimension/canvas.c
parentd56d643d412e06ff1e5239f8ebbd96f716b416bd (diff)
downloaddimension-3ee98f3bac24fd1c70a9de3e0fbe774e762c25b3.tar.xz
Add lots of comments, and some code fixes discovered in the process.
Diffstat (limited to 'libdimension/canvas.c')
-rw-r--r--libdimension/canvas.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 516c978..13b1e9e 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -32,8 +32,6 @@ dmnsn_new_canvas(unsigned int x, unsigned int y)
dmnsn_canvas *canvas = malloc(sizeof(dmnsn_canvas));
if (canvas) {
- /* *canvas exists */
-
/* Set the width and height */
canvas->x = x;
canvas->y = y;
@@ -60,6 +58,7 @@ dmnsn_new_canvas(unsigned int x, unsigned int y)
/* pthread_rwlock_init failed. Destroy the locks we've already made,
free the canvas, and return NULL. We leak memory if destruction
fails (i.e. someone is somehow using an rwlock already). */
+
for (l = 0; l < j; ++l) {
for (k = 0; k < x; ++k) {
if (pthread_rwlock_destroy(&canvas->rwlocks[l*x + k]) != 0) {
@@ -96,8 +95,6 @@ dmnsn_delete_canvas(dmnsn_canvas *canvas)
unsigned int i, j;
if (canvas) {
- /* *canvas exists */
-
/* Destroy the rwlocks */
for (i = 0; i < canvas->x; ++i) {
for (j = 0; j < canvas->y; ++j) {
@@ -121,7 +118,7 @@ dmnsn_get_pixel(const dmnsn_canvas *canvas, unsigned int x, unsigned int y)
{
dmnsn_color color;
dmnsn_rdlock_pixel(canvas, x, y);
- color = canvas->pixels[y*canvas->x + x];
+ color = canvas->pixels[y*canvas->x + x];
dmnsn_unlock_pixel(canvas, x, y);
return color;
}
@@ -132,7 +129,7 @@ dmnsn_set_pixel(dmnsn_canvas *canvas,
unsigned int x, unsigned int y, dmnsn_color color)
{
dmnsn_wrlock_pixel(canvas, x, y);
- canvas->pixels[y*canvas->x + x] = color;
+ canvas->pixels[y*canvas->x + x] = color;
dmnsn_unlock_pixel(canvas, x, y);
}