aboutsummaryrefslogtreecommitdiff
path: root/lib/data/image_types.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/image_types.c')
-rw-r--r--lib/data/image_types.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/lib/data/image_types.c b/lib/data/image_types.c
index 6e8f6b4..3703f07 100644
--- a/lib/data/image_types.c
+++ b/lib/data/image_types.c
@@ -1,40 +1,39 @@
#include <lib/data/image_types.h>
-#include <lib/mem/galloc.h>
#include <stdio.h>
#include <stdlib.h>
Image *create_image(size_t width, size_t height, size_t channels) {
- Image *ip = (Image *)g_malloc(sizeof(Image));
+ Image *ip = (Image *)malloc(sizeof(Image));
if (ip == NULL) {
return NULL;
}
ip->width = width;
ip->height = height;
ip->depth = channels;
- ip->image = (ImageData_t ***)g_malloc(sizeof(ImageData_t **) * ip->height);
+ ip->image = (ImageData_t ***)malloc(sizeof(ImageData_t **) * ip->height);
if (ip->image == NULL) {
fprintf(stderr, "Memory allocation error\n");
- g_free(ip);
+ free(ip);
return NULL;
}
ImageData_t *image_data =
- g_calloc(width * height * channels, sizeof(ImageData_t));
+ calloc(width * height * channels, sizeof(ImageData_t));
if (image_data == NULL) {
fprintf(stderr, "Memory allocation error\n");
- g_free(ip->image);
- g_free(ip);
+ free(ip->image);
+ free(ip);
return NULL;
}
for (size_t y = 0; y < height; y++) {
- ip->image[y] = (ImageData_t **)g_malloc(sizeof(ImageData_t *) * ip->width);
+ ip->image[y] = (ImageData_t **)malloc(sizeof(ImageData_t *) * ip->width);
if (ip->image[y] == NULL) {
fprintf(stderr, "Memory allocation error\n");
for (size_t ty = 0; ty < y; ty++) {
- g_free(ip->image[ty]);
+ free(ip->image[ty]);
}
- g_free(image_data);
- g_free(ip->image);
- g_free(ip);
+ free(image_data);
+ free(ip->image);
+ free(ip);
}
for (size_t x = 0; x < width; x++) {
ip->image[y][x] = &image_data[(y * width + x) * channels];
@@ -44,21 +43,21 @@ Image *create_image(size_t width, size_t height, size_t channels) {
}
Mask *create_image_mask(size_t width, size_t height) {
- Mask *ip = (Mask *)g_malloc(sizeof(Mask));
+ Mask *ip = (Mask *)malloc(sizeof(Mask));
if (ip == NULL) {
return NULL;
}
ip->width = width;
ip->height = height;
- ip->image = (MaskData_t **)g_malloc(sizeof(MaskData_t *) * ip->height);
+ ip->image = (MaskData_t **)malloc(sizeof(MaskData_t *) * ip->height);
if (ip->image == NULL) {
- g_free(ip);
+ free(ip);
return NULL;
}
- MaskData_t *image_data = g_calloc(width * height, sizeof(MaskData_t));
+ MaskData_t *image_data = calloc(width * height, sizeof(MaskData_t));
if (image_data == NULL) {
- g_free(ip->image);
- g_free(ip);
+ free(ip->image);
+ free(ip);
return NULL;
}
for (size_t y = 0; y < height; y++) {
@@ -72,26 +71,26 @@ void free_image(Image *image) {
return;
}
if (image->image == NULL) {
- g_free(image);
+ free(image);
return;
}
if (image->image[0] != NULL) {
if (image->image[0][0] != NULL) {
- g_free(image->image[0][0]);
+ free(image->image[0][0]);
}
} else {
- g_free(image->image);
- g_free(image);
+ free(image->image);
+ free(image);
return;
}
for (size_t y = 0; y < image->height; y++) {
if (image->image[y] != NULL) {
- g_free(image->image[y]);
+ free(image->image[y]);
}
}
- g_free(image->image);
+ free(image->image);
image->image = NULL;
- g_free(image);
+ free(image);
}
void free_image_mask(Mask *image_mask) {
@@ -99,14 +98,14 @@ void free_image_mask(Mask *image_mask) {
return;
}
if (image_mask->image == NULL) {
- g_free(image_mask);
+ free(image_mask);
return;
}
if (image_mask->image[0] != NULL) {
- g_free(image_mask->image[0]);
+ free(image_mask->image[0]);
image_mask->image[0] = NULL;
}
- g_free(image_mask->image);
+ free(image_mask->image);
image_mask->image = NULL;
- g_free(image_mask);
+ free(image_mask);
}