summaryrefslogtreecommitdiff
path: root/py/misc.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-05-10 17:36:41 +0100
committerDamien George <damien.p.george@gmail.com>2014-05-10 17:36:41 +0100
commit1b82e9af5c9b67cae8f7a35abc2dee3989fbdc06 (patch)
tree8f1dd9ece17d60d40d8bd6157fd2a2a01abd082f /py/misc.h
parentad6178bb08de66783b4551ebcd444bf06647326a (diff)
py: Improve handling of memory error in parser.
Parser shouldn't raise exceptions, so needs to check when memory allocation fails. This patch does that for the initial set up of the parser state. Also, we now put the parser object on the stack. It's small enough to go there instead of on the heap. This partially addresses issue #558.
Diffstat (limited to 'py/misc.h')
-rw-r--r--py/misc.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/misc.h b/py/misc.h
index 5eb662409..7f3e83d8c 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -50,6 +50,7 @@ typedef unsigned int uint;
// TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)
#define m_new(type, num) ((type*)(m_malloc(sizeof(type) * (num))))
+#define m_new_maybe(type, num) ((type*)(m_malloc_maybe(sizeof(type) * (num))))
#define m_new0(type, num) ((type*)(m_malloc0(sizeof(type) * (num))))
#define m_new_obj(type) (m_new(type, 1))
#define m_new_obj_var(obj_type, var_type, var_num) ((obj_type*)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))