use SDL stdlib where possible
This commit is contained in:
@ -176,8 +176,8 @@ void render_circle(const CirclePrimitive *circle) {
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
free(vertices);
|
||||
free(indices);
|
||||
SDL_free(vertices);
|
||||
SDL_free(indices);
|
||||
}
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ bool push_to_vertex_buffer_builder(VertexBufferBuilder *builder,
|
||||
if (builder->bytes_left == 0)
|
||||
return false;
|
||||
|
||||
memcpy(builder->mapping, bytes, size);
|
||||
SDL_memcpy(builder->mapping, bytes, size);
|
||||
builder->bytes_left -= size;
|
||||
|
||||
/* trigger data send */
|
||||
|
@ -26,7 +26,7 @@ void render_queue_clear(void) {
|
||||
/* if you're gonna remove it, this is also being done in main.c */
|
||||
for (size_t i = 0; i < arrlenu(ctx.render_queue_2d); ++i) {
|
||||
if (ctx.render_queue_2d[i].type == PRIMITIVE_2D_TEXT) {
|
||||
free(ctx.render_queue_2d[i].text.text);
|
||||
SDL_free(ctx.render_queue_2d[i].text.text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,16 +53,16 @@ static FontData *text_load_font_data(const char *path, int height_px) {
|
||||
TEXT_FONT_TEXTURE_SIZE,
|
||||
TEXT_FONT_TEXTURE_SIZE
|
||||
);
|
||||
free(bitmap);
|
||||
SDL_free(bitmap);
|
||||
|
||||
return font_data;
|
||||
}
|
||||
|
||||
|
||||
static void text_destroy_font_data(FontData *font_data) {
|
||||
free(font_data->file_bytes);
|
||||
SDL_free(font_data->file_bytes);
|
||||
delete_gpu_texture(font_data->texture);
|
||||
free(font_data);
|
||||
SDL_free(font_data);
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ static void ensure_font_cache(const char *font_path, int height_px) {
|
||||
bool is_cached = false;
|
||||
for (size_t i = 0; i < arrlenu(ctx.text_cache.data); ++i) {
|
||||
FontData *font_data = ctx.text_cache.data[i];
|
||||
if ((strcmp(font_path, font_data->file_path) == 0) && height_px == font_data->height_px) {
|
||||
if ((SDL_strcmp(font_path, font_data->file_path) == 0) && height_px == font_data->height_px) {
|
||||
is_cached = true;
|
||||
break;
|
||||
}
|
||||
@ -130,7 +130,7 @@ static FontData *get_font_data(const char *font_path, int height_px) {
|
||||
FontData *font_data = NULL;
|
||||
for (size_t i = 0; i < arrlenu(ctx.text_cache.data); ++i) {
|
||||
font_data = ctx.text_cache.data[i];
|
||||
if ((strcmp(font_path, font_data->file_path) == 0) && height_px == font_data->height_px) {
|
||||
if ((SDL_strcmp(font_path, font_data->file_path) == 0) && height_px == font_data->height_px) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -161,11 +161,9 @@ void text_cache_deinit(TextCache *cache) {
|
||||
void push_text(char *string, Vec2 position, int height_px, Color color, const char *font_path) {
|
||||
ensure_font_cache(font_path, height_px);
|
||||
|
||||
/* the string might not be around by the time it's used, so copy it */
|
||||
/* the original string might not be around by the time it's used, so copy it */
|
||||
/* TODO: arena */
|
||||
/* NOTE: can we trust strlen? */
|
||||
char *dup_string = cmalloc(strlen(string) + 1);
|
||||
strcpy(dup_string, string);
|
||||
char *dup_string = SDL_strdup(string);
|
||||
|
||||
TextPrimitive text = {
|
||||
.color = color,
|
||||
|
Reference in New Issue
Block a user