REFACTOR: Completely remade the error handling format. Using pre-defined
error codes and error messages to make it easier to debug problems.
This commit is contained in:
+10
-9
@@ -3,6 +3,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "image/utils.h"
|
||||
|
||||
unsigned int
|
||||
u32_put_alpha(const unsigned int clr, const unsigned char alpha)
|
||||
{
|
||||
@@ -103,10 +105,10 @@ u32_mask(const unsigned int clr, const char keep)
|
||||
return clr & (BYTE_A | BYTE_B);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
return FAILURE;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -114,11 +116,8 @@ u32_rotl(const unsigned int clr, const int n)
|
||||
{
|
||||
if (n > 8)
|
||||
{
|
||||
printf(
|
||||
"ERROR: %i is greater than 8 results in black "
|
||||
"pixels, please use values less than 8\n",
|
||||
n);
|
||||
exit(10);
|
||||
LOGERROR(ERR_INVALID_SIZE);
|
||||
return ERR_INVALID_SIZE;
|
||||
}
|
||||
unsigned int red = DECODE_R(clr);
|
||||
unsigned int green = DECODE_G(clr);
|
||||
@@ -261,13 +260,15 @@ box_blur(const unsigned int* src_buf, const PPM* img, const int radius)
|
||||
unsigned int* first_pass = malloc(img->len * sizeof(unsigned int));
|
||||
if (!first_pass)
|
||||
{
|
||||
return 0;
|
||||
LOGERROR(ERR_BUF_NULL);
|
||||
return NULL;
|
||||
}
|
||||
unsigned int* dst_buf = malloc(img->len * sizeof(unsigned int));
|
||||
if (!dst_buf)
|
||||
{
|
||||
free(first_pass);
|
||||
return 0;
|
||||
LOGERROR(ERR_BUF_NULL);
|
||||
return NULL;
|
||||
}
|
||||
for (int y = 0; y < img->height; y++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user