diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-05-27 14:01:20 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-05-27 14:01:20 -0400 |
commit | b70fa29511471e8a85f9b8c3e8947dbb3c21dedb (patch) | |
tree | 9d2e066dc2ad11d918ca12a1e073c163d4d4d79d /libdimension/pattern.c | |
parent | df33e223baa85b600863fc1b38850a5c37680632 (diff) | |
download | dimension-b70fa29511471e8a85f9b8c3e8947dbb3c21dedb.tar.xz |
pattern: Kill ->ptr field.
Diffstat (limited to 'libdimension/pattern.c')
-rw-r--r-- | libdimension/pattern.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libdimension/pattern.c b/libdimension/pattern.c index 2a7dca6..56c7c48 100644 --- a/libdimension/pattern.c +++ b/libdimension/pattern.c @@ -25,25 +25,35 @@ #include "dimension-internal.h" +static void +dmnsn_default_pattern_free_fn(dmnsn_pattern *pattern) +{ + dmnsn_free(pattern); +} + /* Allocate a dummy pattern */ dmnsn_pattern * dmnsn_new_pattern(void) { dmnsn_pattern *pattern = DMNSN_MALLOC(dmnsn_pattern); - pattern->free_fn = NULL; - DMNSN_REFCOUNT_INIT(pattern); + dmnsn_init_pattern(pattern); return pattern; } +/* Initialize a pattern */ +void +dmnsn_init_pattern(dmnsn_pattern *pattern) +{ + pattern->free_fn = dmnsn_default_pattern_free_fn; + DMNSN_REFCOUNT_INIT(pattern); +} + /* Delete a pattern */ void dmnsn_delete_pattern(dmnsn_pattern *pattern) { if (DMNSN_DECREF(pattern)) { - if (pattern->free_fn) { - pattern->free_fn(pattern->ptr); - } - dmnsn_free(pattern); + pattern->free_fn(pattern); } } |