Browse Source

relocate: assert that srcptr use on non-nullable only

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1458 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
master
Xuefer 8 years ago
parent
commit
975170470f
  1. 9
      processor/head.m4
  2. 2
      processor/main.m4

9
processor/head.m4

@ -83,6 +83,15 @@ typedef char zstr_char;
#define ptradd(type, ptr, ptrdiff) ((type) (((char *) (ptr)) + (ptrdiff)))
#define ptrsub(ptr1, ptr2) (((char *) (ptr1)) - ((char *) (ptr2)))
#ifdef NDEBUG
#define notnullable(ptr) (ptr)
#else
static inline void *notnullable(void *ptr)
{
assert(ptr);
return ptr;
}
#endif
dnl }}}
dnl {{{ _xc_processor_t
typedef struct _xc_processor_t {

2
processor/main.m4

@ -25,7 +25,7 @@ dnl ============
define(`INDENT', `xc_dprint_indent(indent);')
dnl }}}
dnl {{{ SRCPTR_EX(1:type, 2:elm)
define(`SRCPTR_EX', `IFRELOCATE(`($2 ? ptradd($1 *, $2, ptrdiff) : NULL)', `$2')')
define(`SRCPTR_EX', `IFRELOCATE(`ptradd($1 *, notnullable($2), ptrdiff)', `$2')')
dnl }}}
dnl {{{ ALLOC(1:dst, 2:type, 3:count=1, 4:clean=false, 5:realtype=$2)
define(`ALLOC', `

Loading…
Cancel
Save