Skip to content

Commit

Permalink
Added destroy methods to some functions to fix memory leaks. (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws authored Jul 9, 2018
1 parent 10621e6 commit 124b3df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/cairo.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef struct _cairo_matrix {
double x0;
double y0;
static tolua_outside cairo_matrix_t* create_cairo_matrix_t @ create();
static tolua_outside void destroy_cairo_matrix_t @ destroy(cairo_matrix_t *pointer);
} cairo_matrix_t;
typedef int cairo_bool_t;

Expand Down Expand Up @@ -410,6 +411,7 @@ typedef struct {
double x_advance;
double y_advance;
static tolua_outside cairo_text_extents_t* create_cairo_text_extents_t @ create();
static tolua_outside void destroy_cairo_text_extents_t @ destroy(cairo_text_extents_t *pointer);
} cairo_text_extents_t;

typedef struct {
Expand All @@ -419,6 +421,7 @@ typedef struct {
double max_x_advance;
double max_y_advance;
static tolua_outside cairo_font_extents_t* create_cairo_font_extents_t @ create();
static tolua_outside void destroy_cairo_font_extents_t @ destroy(cairo_font_extents_t *pointer);
} cairo_font_extents_t;

typedef enum _cairo_font_slant {
Expand Down
13 changes: 13 additions & 0 deletions lua/libcairo-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ cairo_matrix_t *create_cairo_matrix_t(void) {
return calloc(1, sizeof(cairo_matrix_t));
}

void destroy_cairo_text_extents_t(cairo_text_extents_t *pointer) {
free(pointer);
}

void destroy_cairo_font_extents_t(cairo_font_extents_t *pointer) {
free(pointer);
}

void destroy_cairo_matrix_t(cairo_matrix_t *pointer) {
free(pointer);
}


#endif /* _LIBCAIRO_HELPER_H_ */

0 comments on commit 124b3df

Please sign in to comment.