diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-07-09 16:24:13 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-07-09 16:24:13 +0000 |
commit | 9a634a53f0d7135ef82e6888a89091db173c7f7f (patch) | |
tree | b424545f9ad05288f6d94048bea5fc48e90aeff0 | |
parent | 28de29088084e5f544b79760748ef28739b5c769 (diff) | |
download | dimension-9a634a53f0d7135ef82e6888a89091db173c7f7f.tar.xz |
Code formatting.
-rw-r--r-- | libdimension/dimension.h | 5 | ||||
-rw-r--r-- | libdimension/dimension/error.h | 2 | ||||
-rw-r--r-- | libdimension/inlines.c | 2 | ||||
-rw-r--r-- | libdimension/png.c | 44 | ||||
-rw-r--r-- | libdimension/raytrace.c | 9 | ||||
-rw-r--r-- | tests/tests.c | 4 | ||||
-rw-r--r-- | tests/testsxx.cpp | 4 | ||||
-rw-r--r-- | tests/warning.c | 16 |
8 files changed, 55 insertions, 31 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, diff --git a/tests/tests.c b/tests/tests.c index cbf7ff8..3696216 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -267,8 +267,8 @@ dmnsn_progressbar_async(const char *str, const dmnsn_progress *progress) /* Create the worker thread */ if (pthread_create(&barprogress->thread, NULL, &dmnsn_progressbar_thread, - payload) - != 0) { + payload) != 0) + { dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't start progress bar background thread."); } diff --git a/tests/testsxx.cpp b/tests/testsxx.cpp index 908d0f8..aaeb546 100644 --- a/tests/testsxx.cpp +++ b/tests/testsxx.cpp @@ -116,8 +116,8 @@ namespace Dimension /* Create the worker thread */ if (pthread_create(&barprogress->thread, NULL, &progressbar_thread, - reinterpret_cast<void*>(payload)) - != 0) { + reinterpret_cast<void*>(payload)) != 0) + { throw Dimension_Error("Couldn't create background thread."); } diff --git a/tests/warning.c b/tests/warning.c index 9b8ba12..7b6aac3 100644 --- a/tests/warning.c +++ b/tests/warning.c @@ -25,18 +25,26 @@ int main() { - if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) return EXIT_FAILURE; + if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) { + return EXIT_FAILURE; + } dmnsn_set_resilience(DMNSN_SEVERITY_LOW); - if (dmnsn_get_resilience() != DMNSN_SEVERITY_LOW) return EXIT_FAILURE; + if (dmnsn_get_resilience() != DMNSN_SEVERITY_LOW) { + return EXIT_FAILURE; + } dmnsn_set_resilience(DMNSN_SEVERITY_MEDIUM); - if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) return EXIT_FAILURE; + if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) { + return EXIT_FAILURE; + } dmnsn_error(DMNSN_SEVERITY_LOW, "This warning is expected."); dmnsn_set_resilience(DMNSN_SEVERITY_HIGH); - if (dmnsn_get_resilience() != DMNSN_SEVERITY_HIGH) return EXIT_FAILURE; + if (dmnsn_get_resilience() != DMNSN_SEVERITY_HIGH) { + return EXIT_FAILURE; + } dmnsn_error(DMNSN_SEVERITY_LOW, "This warning is expected."); dmnsn_error(DMNSN_SEVERITY_MEDIUM, "This warning is expected."); |