Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Aug 25, 2024
1 parent 2dc91ca commit 1da5f47
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 193 deletions.
6 changes: 6 additions & 0 deletions extensions/pntr_cute_png.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ unsigned char* pntr_cute_png_save_image_to_memory(pntr_image* image, pntr_image_
#ifndef PNTR_CUTE_PNG_IMPLEMENTATION
#define PNTR_CUTE_PNG_IMPLEMENTATION

#ifndef PNTR_MEMCMP
#include <string.h>
#define PNTR_MEMCMP(ptr1, ptr2, num) memcmp(ptr1, ptr2, num)
#endif // PNTR_MEMCMP

#ifndef PNTR_NO_CUTE_PNG_IMPLEMENTATION
#define CUTE_PNG_IMPLEMENTATION
#define CUTE_PNG_ALLOCA PNTR_MALLOC
#define CUTE_PNG_ALLOC PNTR_MALLOC
#define CUTE_PNG_FREE PNTR_FREE
#define CUTE_PNG_CALLOC(num, size) PNTR_MALLOC((num) * (size))
#define CUTE_PNG_REALLOC PNTR_REALLOC
#define CUTE_PNG_MEMCMP PNTR_MEMCMP
#define CUTE_PNG_MEMCPY PNTR_MEMCPY
#define CUTE_PNG_MEMSET PNTR_MEMSET
#define CUTE_PNG_FPRINTF (void)
Expand Down
16 changes: 11 additions & 5 deletions external/cute_png.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
CUTE_PNG_CALLOC
CUTE_PNG_REALLOC
CUTE_PNG_MEMCPY
CUTE_PNG_MEMCMP
CUTE_PNG_MEMSET
CUTE_PNG_ASSERT
CUTE_PNG_FPRINTF
Expand Down Expand Up @@ -261,6 +262,11 @@ struct cp_atlas_image_t
#define CUTE_PNG_MEMCPY memcpy
#endif

#if !defined(CUTE_PNG_MEMCMP)
#include <string.h>
#define CUTE_PNG_MEMCMP memcmp
#endif

#if !defined(CUTE_PNG_MEMSET)
#include <string.h>
#define CUTE_PNG_MEMSET memset
Expand Down Expand Up @@ -947,7 +953,7 @@ static const uint8_t* cp_chunk(cp_raw_png_t* png, const char* chunk, uint32_t mi
uint32_t len = cp_make32(png->p);
const uint8_t* start = png->p;

if (!memcmp(start + 4, chunk, 4) && len >= minlen)
if (!CUTE_PNG_MEMCMP(start + 4, chunk, 4) && len >= minlen)
{
int offset = len + 12;

Expand All @@ -970,7 +976,7 @@ static const uint8_t* cp_find(cp_raw_png_t* png, const char* chunk, uint32_t min
start = png->p;
png->p += len + 12;

if (!memcmp(start+4, chunk, 4) && len >= minlen && png->p <= png->end)
if (!CUTE_PNG_MEMCMP(start+4, chunk, 4) && len >= minlen && png->p <= png->end)
return start + 8;
}

Expand Down Expand Up @@ -1090,7 +1096,7 @@ cp_image_t cp_load_png_mem(const void* png_data, int png_length)
png.p = (uint8_t*)png_data;
png.end = (uint8_t*)png_data + png_length;

CUTE_PNG_CHECK(!memcmp(png.p, sig, 8), "incorrect file signature (is this a png file?)");
CUTE_PNG_CHECK(!CUTE_PNG_MEMCMP(png.p, sig, 8), "incorrect file signature (is this a png file?)");
png.p += 8;

ihdr = cp_chunk(&png, "IHDR", 13);
Expand Down Expand Up @@ -1251,7 +1257,7 @@ void cp_load_png_wh(const void* png_data, int png_length, int* w_out, int* h_out
if (w_out) *w_out = 0;
if (h_out) *h_out = 0;

CUTE_PNG_CHECK(!memcmp(png.p, sig, 8), "incorrect file signature (is this a png file?)");
CUTE_PNG_CHECK(!CUTE_PNG_MEMCMP(png.p, sig, 8), "incorrect file signature (is this a png file?)");
png.p += 8;

ihdr = cp_chunk(&png, "IHDR", 13);
Expand Down Expand Up @@ -1319,7 +1325,7 @@ cp_indexed_image_t cp_load_indexed_png_mem(const void *png_data, int png_length)
png.p = (uint8_t*)png_data;
png.end = (uint8_t*)png_data + png_length;

CUTE_PNG_CHECK(!memcmp(png.p, sig, 8), "incorrect file signature (is this a png file?)");
CUTE_PNG_CHECK(!CUTE_PNG_MEMCMP(png.p, sig, 8), "incorrect file signature (is this a png file?)");
png.p += 8;

ihdr = cp_chunk(&png, "IHDR", 13);
Expand Down
Loading

0 comments on commit 1da5f47

Please sign in to comment.