diff options
Diffstat (limited to 'libdimension/pattern.c')
-rw-r--r-- | libdimension/pattern.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libdimension/pattern.c b/libdimension/pattern.c index b266527..368755a 100644 --- a/libdimension/pattern.c +++ b/libdimension/pattern.c @@ -30,8 +30,9 @@ dmnsn_pattern * dmnsn_new_pattern(void) { dmnsn_pattern *pattern = dmnsn_malloc(sizeof(dmnsn_pattern)); - pattern->trans = dmnsn_identity_matrix(); - pattern->free_fn = NULL; + pattern->trans = dmnsn_identity_matrix(); + pattern->free_fn = NULL; + pattern->refcount = 1; return pattern; } @@ -39,10 +40,12 @@ dmnsn_new_pattern(void) void dmnsn_delete_pattern(dmnsn_pattern *pattern) { - if (pattern->free_fn) { - pattern->free_fn(pattern->ptr); + if (DMNSN_DECREF(pattern)) { + if (pattern->free_fn) { + pattern->free_fn(pattern->ptr); + } + dmnsn_free(pattern); } - dmnsn_free(pattern); } /* Precompute the transformation matrix inverse */ |