summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension.h5
-rw-r--r--libdimension/dimension/error.h2
-rw-r--r--libdimension/inlines.c2
-rw-r--r--libdimension/png.c44
-rw-r--r--libdimension/raytrace.c9
5 files changed, 39 insertions, 23 deletions
diff --git a/libdimension/dimension.h b/libdimension/dimension.h
index 989eb24..684748d 100644
--- a/libdimension/dimension.h
+++ b/libdimension/dimension.h
@@ -38,12 +38,12 @@
#ifdef __cplusplus
/* C++ inline semantics */
#define DMNSN_INLINE inline
- #elif (__STDC_VERSION__ >= 199901L)
+ #elif __STDC_VERSION__ >= 199901L
/* C99 inline semantics */
#define DMNSN_INLINE inline
#elif defined(__GNUC__)
/* GCC inline semantics */
- #define DMNSN_INLINE __extension__ extern __inline__
+ #define DMNSN_INLINE __extension__ extern __inline__
#else
/* Unknown C - mark functions static and hope the compiler is smart enough
to inline them */
@@ -56,6 +56,7 @@
extern "C" {
#endif
+/* Include all the libdimension headers */
#include <dimension/error.h>
#include <dimension/array.h>
#include <dimension/progress.h>
diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h
index 0d5b0b5..cc38d65 100644
--- a/libdimension/dimension/error.h
+++ b/libdimension/dimension/error.h
@@ -36,7 +36,7 @@ typedef enum {
#ifdef __GNUC__
#define DMNSN_FUNC __PRETTY_FUNCTION__
-#elif (__STDC_VERSION__ >= 199901L)
+#elif __STDC_VERSION__ >= 199901L
#define DMNSN_FUNC __func__
#else
#define DMNSN_FUNC __FILE__
diff --git a/libdimension/inlines.c b/libdimension/inlines.c
index 915107f..1c07dd1 100644
--- a/libdimension/inlines.c
+++ b/libdimension/inlines.c
@@ -23,7 +23,7 @@
#ifdef __cplusplus
/* C++ inline semantics */
#define DMNSN_INLINE inline
-#elif (__STDC_VERSION__ >= 199901L)
+#elif __STDC_VERSION__ >= 199901L
/* C99 inline semantics */
#define DMNSN_INLINE
#elif defined(__GNUC__)
diff --git a/libdimension/png.c b/libdimension/png.c
index 8a23214..83eb38e 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -151,8 +151,8 @@ dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas, FILE *file)
/* Create the worker thread */
if (pthread_create(&progress->thread, NULL, &dmnsn_png_write_canvas_thread,
- payload)
- != 0) {
+ payload) != 0)
+ {
free(payload);
dmnsn_delete_progress(progress);
return NULL;
@@ -192,8 +192,8 @@ dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file)
/* Create the worker thread */
if (pthread_create(&progress->thread, NULL, &dmnsn_png_read_canvas_thread,
- payload)
- != 0) {
+ payload) != 0)
+ {
free(payload);
dmnsn_delete_progress(progress);
return NULL;
@@ -254,7 +254,10 @@ dmnsn_png_write_canvas_impl(dmnsn_progress *progress,
dmnsn_color color;
dmnsn_sRGB sRGB;
- if (!file) return 1; /* file was NULL */
+ if (!file) {
+ /* file was NULL */
+ return 1;
+ }
width = canvas->x;
height = canvas->y;
@@ -262,7 +265,10 @@ dmnsn_png_write_canvas_impl(dmnsn_progress *progress,
dmnsn_new_progress_element(progress, height);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) return 1; /* Couldn't create libpng write struct */
+ if (!png_ptr) {
+ /* Couldn't create libpng write struct */
+ return 1;
+ }
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
@@ -274,7 +280,7 @@ dmnsn_png_write_canvas_impl(dmnsn_progress *progress,
/* libpng will longjmp here if it encounters an error from here on */
if (setjmp(png_jmpbuf(png_ptr))) {
/* libpng error */
- if (row) free(row);
+ free(row);
png_destroy_write_struct(&png_ptr, &info_ptr);
return 1;
}
@@ -426,15 +432,22 @@ dmnsn_png_read_canvas_impl(dmnsn_progress *progress, FILE *file)
"Couldn't unlock thread-specific pointer mutex.");
}
- if (!file) return NULL; /* file was NULL */
+ if (!file) {
+ /* file was NULL */
+ return NULL;
+ }
fread(header, 1, 8, file);
- if (png_sig_cmp(header, 0, 8)) return NULL; /* file is not a PNG file, or the
- read failed */
+ if (png_sig_cmp(header, 0, 8)) {
+ /* file is not a PNG file, or the read failed */
+ return NULL;
+ }
/* Create the libpng read struct */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) return NULL;
+ if (!png_ptr) {
+ return NULL;
+ }
/* Create the libpng info struct */
info_ptr = png_create_info_struct(png_ptr);
@@ -446,8 +459,8 @@ dmnsn_png_read_canvas_impl(dmnsn_progress *progress, FILE *file)
/* libpng will longjmp here if it encounters an error from here on */
if (setjmp(png_jmpbuf(png_ptr))) {
/* libpng error */
- if (row_pointers) free(row_pointers);
- if (image) free(image);
+ free(row_pointers);
+ free(image);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}
@@ -481,8 +494,9 @@ dmnsn_png_read_canvas_impl(dmnsn_progress *progress, FILE *file)
png_set_tRNS_to_alpha(png_ptr);
}
if (color_type == PNG_COLOR_TYPE_GRAY
- || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
- png_set_gray_to_rgb(png_ptr);
+ || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ {
+ png_set_gray_to_rgb(png_ptr);
}
png_set_invert_alpha(png_ptr);
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 0f00d24..7c3637e 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -60,8 +60,8 @@ dmnsn_raytrace_scene_async(dmnsn_scene *scene)
payload->scene = scene;
if (pthread_create(&progress->thread, NULL, &dmnsn_raytrace_scene_thread,
- payload)
- != 0) {
+ payload) != 0)
+ {
free(payload);
dmnsn_delete_progress(progress);
return NULL;
@@ -130,8 +130,9 @@ dmnsn_raytrace_scene_multithread(dmnsn_raytrace_payload *payload)
payloads[i].threads = nthreads;
if (pthread_create(&threads[i], NULL,
- &dmnsn_raytrace_scene_multithread_thread, &payloads[i])
- != 0) {
+ &dmnsn_raytrace_scene_multithread_thread,
+ &payloads[i]) != 0)
+ {
for (j = 0; j < i; ++j) {
if (pthread_join(threads[i], &ptr)) {
dmnsn_error(DMNSN_SEVERITY_MEDIUM,