Skip to content

Commit

Permalink
Fix potential memory leaks in a multithreaded environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Sep 12, 2024
1 parent e0a78f6 commit c493f5b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/plutovg-canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void plutovg_stroke_data_copy(plutovg_stroke_data_t* stroke, const plutov

static plutovg_paint_t* plutovg_paint_default(void)
{
static PLUTOVG_THREAD_LOCAL plutovg_solid_paint_t paint = {
static plutovg_solid_paint_t paint = {
{1, PLUTOVG_PAINT_TYPE_COLOR},
{0.f, 0.f, 0.f, 1.f}
};
Expand Down
2 changes: 1 addition & 1 deletion source/plutovg-paint.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int plutovg_color_parse(plutovg_color_t* color, const char* data, int length)
return it - data;
}

static PLUTOVG_THREAD_LOCAL plutovg_paint_t* freed_paint[3];
static plutovg_paint_t* freed_paint[3];

static void* plutovg_paint_create(plutovg_paint_type_t type, size_t size)
{
Expand Down
10 changes: 0 additions & 10 deletions source/plutovg-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
#include <float.h>
#include <math.h>

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define PLUTOVG_THREAD_LOCAL _Thread_local
#elif defined(_MSC_VER)
#define PLUTOVG_THREAD_LOCAL __declspec(thread)
#elif defined(__GNUC__)
#define PLUTOVG_THREAD_LOCAL __thread
#else
#define PLUTOVG_THREAD_LOCAL
#endif

#define plutovg_min(a, b) ((a) < (b) ? (a) : (b))
#define plutovg_max(a, b) ((a) > (b) ? (a) : (b))
#define plutovg_clamp(v, lo, hi) ((v) < (lo) ? (lo) : (hi) < (v) ? (hi) : (v))
Expand Down

0 comments on commit c493f5b

Please sign in to comment.