Skip to content

Commit

Permalink
guard the malloc and debug defines into implementation block
Browse files Browse the repository at this point in the history
  • Loading branch information
lowfatcode committed Jul 15, 2024
1 parent 7557452 commit ababadf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions examples/c/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void blend_tile(const pp_tile_t *t) {
}

// draw border of tile for debugging
colour box = create_colour(160, 180, 200, 150);
/*colour box = create_colour(160, 180, 200, 150);
for(int32_t x = t->x; x < t->x + t->w; x++) {
buffer[t->y][x] = blend(buffer[t->y][x], box);
buffer[t->y + t->h][x] = blend(buffer[t->y + t->h][x], box);
}
for(int32_t y = t->y; y < t->y + t->h; y++) {
buffer[y][t->x] = blend(buffer[y][t->x], box);
buffer[y][t->x + t->w] = blend(buffer[y][t->x + t->w], box);
}
}*/
}


Expand Down
26 changes: 13 additions & 13 deletions pretty-poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
#include <math.h>
#include <stdbool.h>

#ifndef PP_MALLOC
#define PP_MALLOC(size) malloc(size)
#define PP_REALLOC(p, size) realloc(p, size)
#define PP_FREE(p) free(p)
#endif

#ifndef PP_COORD_TYPE
#define PP_COORD_TYPE float
#endif
Expand All @@ -63,12 +57,6 @@
#include "hardware/interp.h"
#endif

#ifdef PP_DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -145,6 +133,18 @@ pp_rect_t pp_polygon_bounds(pp_poly_t *p);

#ifdef PP_IMPLEMENTATION

#ifndef PP_MALLOC
#define PP_MALLOC(size) malloc(size)
#define PP_REALLOC(p, size) realloc(p, size)
#define PP_FREE(p) free(p)
#endif

#ifdef PP_DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif

pp_rect_t _pp_clip = (pp_rect_t){-INT_MAX, -INT_MAX, INT_MAX, INT_MAX};
pp_tile_callback_t _pp_tile_callback = NULL;
pp_antialias_t _pp_antialias = PP_AA_X4;
Expand Down Expand Up @@ -437,7 +437,7 @@ pp_rect_t render_nodes(pp_rect_t *tb) {

unsigned char* row_data = &tile_buffer[(y >> _pp_antialias) * PP_TILE_BUFFER_SIZE];

for(int i = 0; i < node_counts[y]; i += 2) {
for(uint32_t i = 0; i < node_counts[y]; i += 2) {
int sx = nodes[y][i + 0];
int ex = nodes[y][i + 1];

Expand Down

0 comments on commit ababadf

Please sign in to comment.