Added destroy methods to some functions to fix memory leaks. (#535)

This commit is contained in:
Brenden Matthews
2018-07-08 20:51:44 -04:00
committed by GitHub
parent 10621e61b1
commit 124b3dfaa4
2 changed files with 16 additions and 0 deletions

View File

@@ -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;
@@ -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 {
@@ -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 {

View File

@@ -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_ */