diff options
author | Christian C <cc@localhost> | 2025-04-01 17:38:32 -0700 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-04-01 17:38:32 -0700 |
commit | a18cea2fef7aa1545c9a984b60919541b26a6f84 (patch) | |
tree | d1ab991e28b701bdfdc9035704389ad6c57391c9 /lib/data | |
parent | 2bc54ac42b831a7dfcba26c2d12ba002f80a5e40 (diff) |
Clang Format
Diffstat (limited to 'lib/data')
-rw-r--r-- | lib/data/image_types.c | 29 |
1 files changed, 13 insertions, 16 deletions
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 <lib/data/image_types.h> -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> -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; |