Mercurial > MadButterfly
changeset 213:a0a3196b1a05
Refactory pointer computation into a macro.
- It is hard to read a complicate pointer calculation. A macro can make
it more easy to be read.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 12 Dec 2008 09:35:27 +0800 |
parents | 5f144bab5de1 |
children | 064ff6318dfc ad5c7a5c2c39 |
files | tools/mb_c_source.m4 |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/mb_c_source.m4 Fri Dec 12 09:10:05 2008 +0800 +++ b/tools/mb_c_source.m4 Fri Dec 12 09:35:27 2008 +0800 @@ -355,6 +355,9 @@ #ifndef MB_LSYM_GET_OBJ_WITH_NAME #define MB_LSYM_GET_OBJ_WITH_NAME + +#define MB_SPRITE_OFF_2_PTR(x, off) (((void *)(x)) + (off)) + static mb_obj_t *mb_lsym_get_obj_with_name(mb_sprite_lsym_t *lsym, const char *sym) { int i; @@ -362,7 +365,8 @@ for(i = 0; i < lsym->num_entries; i++) { if(strcmp(lsym->entries[i].sym, sym) != 0) continue; - return (mb_obj_t *)*((int*)(((void *)lsym) + lsym->entries[i].offset)); + return *(mb_obj_t **)MB_SPRITE_OFF_2_PTR(lsym, + lsym->entries[i].offset); } return NULL; }