# HG changeset patch # User Thinker K.F. Li # Date 1229045727 -28800 # Node ID a0a3196b1a05513c8724fe6641fee1f5c0dba773 # Parent 5f144bab5de120e086246ff6274e892116ef1bba 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. diff -r 5f144bab5de1 -r a0a3196b1a05 tools/mb_c_source.m4 --- 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; }