From a18cea2fef7aa1545c9a984b60919541b26a6f84 Mon Sep 17 00:00:00 2001 From: Christian C Date: Tue, 1 Apr 2025 17:38:32 -0700 Subject: Clang Format --- lib/data/image_types.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'lib/data') diff --git a/lib/data/image_types.c b/lib/data/image_types.c index 0e40ad1..9a0e0ce 100644 --- a/lib/data/image_types.c +++ b/lib/data/image_types.c @@ -1,10 +1,9 @@ #include -#include #include +#include -Image* create_image(size_t width, size_t height, size_t channels) -{ - Image* ip = (Image*)malloc(sizeof(Image)); +Image *create_image(size_t width, size_t height, size_t channels) { + Image *ip = (Image *)malloc(sizeof(Image)); if (ip == NULL) { return NULL; } @@ -17,7 +16,8 @@ Image* create_image(size_t width, size_t height, size_t channels) free(ip); return NULL; } - ImageData_t *image_data = calloc(width * height*channels, sizeof(ImageData_t)); + ImageData_t *image_data = + calloc(width * height * channels, sizeof(ImageData_t)); if (image_data == NULL) { fprintf(stderr, "Memory allocation error\n"); free(ip->image); @@ -36,39 +36,37 @@ Image* create_image(size_t width, size_t height, size_t channels) free(ip); } for (size_t x = 0; x < width; x++) { - ip->image[y][x] = &image_data[(y * width + x)*channels]; + ip->image[y][x] = &image_data[(y * width + x) * channels]; } } return ip; } -Mask* create_image_mask(size_t width, size_t height) -{ - Mask* ip = (Mask*)malloc(sizeof(Mask)); +Mask *create_image_mask(size_t width, size_t height) { + Mask *ip = (Mask *)malloc(sizeof(Mask)); if (ip == NULL) { return NULL; } ip->width = width; ip->height = height; - ip->image = (MaskData_t**)malloc(sizeof(MaskData_t*) * ip->height); + ip->image = (MaskData_t **)malloc(sizeof(MaskData_t *) * ip->height); if (ip->image == NULL) { free(ip); return NULL; } - MaskData_t* image_data = calloc(width*height, sizeof(MaskData_t)); + MaskData_t *image_data = calloc(width * height, sizeof(MaskData_t)); if (image_data == NULL) { free(ip->image); free(ip); return NULL; } for (size_t y = 0; y < height; y++) { - ip->image[y] = &image_data[y*width]; + ip->image[y] = &image_data[y * width]; } return ip; } -void free_image(Image* image) -{ +void free_image(Image *image) { if (image->image[0] != NULL) { free(image->image[0]); image->image[0] = NULL; @@ -82,8 +80,7 @@ void free_image(Image* image) } } -void free_image_mask(Mask* image_mask) -{ +void free_image_mask(Mask *image_mask) { if (image_mask->image[0] != NULL) { free(image_mask->image[0]); image_mask->image[0] = NULL; -- cgit v1.2.1