summaryrefslogtreecommitdiffstats
path: root/dimension/common.prologue
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-07 14:26:15 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-07 14:34:52 -0400
commit2b087cb45ae91f90492a935625570d7d42ee3ecb (patch)
treea464213b08d04c8c91c8879a84e534f895c84378 /dimension/common.prologue
parent7d6663eeb68bf9d0a3dff86128827c0c1d85df69 (diff)
downloaddimension-2b087cb45ae91f90492a935625570d7d42ee3ecb.tar.xz
New dmnsn_malloc() function, and friends.
I'm tired of checking for malloc failures everywhere, considering it never happens. So just bail out whenever it does. A lot of stuff is guaranteed to succeed if it returns now.
Diffstat (limited to 'dimension/common.prologue')
-rw-r--r--dimension/common.prologue6
1 files changed, 1 insertions, 5 deletions
diff --git a/dimension/common.prologue b/dimension/common.prologue
index 68f4f1a..06ccdb3 100644
--- a/dimension/common.prologue
+++ b/dimension/common.prologue
@@ -57,17 +57,13 @@ dmnsn_new_astnode(dmnsn_astnode_type type, YYLTYPE lloc)
.children = dmnsn_new_array(sizeof(dmnsn_astnode)),
.ptr = NULL,
.free_fn = NULL,
- .refcount = malloc(sizeof(unsigned int)),
+ .refcount = dmnsn_malloc(sizeof(unsigned int)),
.filename = lloc.first_filename,
.line = lloc.first_line,
.col = lloc.first_column
};
- if (!astnode.refcount) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't allocate reference count.");
- }
*astnode.refcount = 1;
-
return astnode;
}