diff options
author | Damien <damien.p.george@gmail.com> | 2013-12-21 18:17:45 +0000 |
---|---|---|
committer | Damien <damien.p.george@gmail.com> | 2013-12-21 18:17:45 +0000 |
commit | d99b05282d14ceb0163cbcd059aa37bdb415af43 (patch) | |
tree | 978135f9fe83d3c4d5b3c95f84cb104c0092936a /py/misc.h | |
parent | e2880aa2fdc75298df487df7519d483acb03959c (diff) | |
download | micropython-d99b05282d14ceb0163cbcd059aa37bdb415af43.tar.gz micropython-d99b05282d14ceb0163cbcd059aa37bdb415af43.zip |
Change object representation from 1 big union to individual structs.
A big change. Micro Python objects are allocated as individual structs
with the first element being a pointer to the type information (which
is itself an object). This scheme follows CPython. Much more flexible,
not necessarily slower, uses same heap memory, and can allocate objects
statically.
Also change name prefix, from py_ to mp_ (mp for Micro Python).
Diffstat (limited to 'py/misc.h')
-rw-r--r-- | py/misc.h | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -19,6 +19,8 @@ typedef unsigned int uint; #define m_new(type, num) ((type*)(m_malloc(sizeof(type) * (num)))) #define m_new0(type, num) ((type*)(m_malloc0(sizeof(type) * (num)))) #define m_renew(type, ptr, num) ((type*)(m_realloc((ptr), 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))) void m_free(void *ptr); void *m_malloc(int num_bytes); |