void (*_su_home_destroy_mutexes)(void *mutex);
+#if HAVE_FREE_NULL
+#define safefree(x) free((x))
+#else
+su_inline void safefree(void *b) { b ? free(b) : (void)0; }
+#endif
+
#define MEMLOCK(h) \
((void)((h) && (h)->suh_lock ? _su_home_locker((h)->suh_lock) : 0), (h)->suh_blocks)
#define UNLOCK(h) ((void)((h) && (h)->suh_lock ? _su_home_unlocker((h)->suh_lock) : 0), NULL)
home->suh_blocks = b2;
if (sub && !sub->sub_auto)
- free(sub);
+ safefree(sub);
sub = b2;
}
subhome->suh_blocks = su_hash_alloc(SUB_N);
if (!subhome->suh_blocks)
- return (void)free(data), NULL;
+ return (void)safefree(data), NULL;
subhome->suh_size = (unsigned)size;
subhome->suh_blocks->sub_parent = home;
if (home->suh_blocks)
home->suh_blocks->sub_hauto = 0;
else
- free(home), home = NULL;
+ safefree(home), home = NULL;
}
return home;
int hauto = sub->sub_hauto;
_su_home_deinit(home);
if (!hauto)
- free(home);
+ safefree(home);
/* UNLOCK(home); */
return 1;
}
UNLOCK(home);
}
- free(data);
+ safefree(data);
}
/** Check home consistency.
}
else if (su_is_preloaded(b, b->sub_nodes[i].sua_data))
continue;
- safe_free(b->sub_nodes[i].sua_data);
-
+
+ safefree(b->sub_nodes[i].sua_data);
}
}
Define this as 1 if your compiler puts the variable argument list nicely in memory])
fi
+### ======================================================================
+### Test if free(0) fails
+###
+
+AC_CACHE_CHECK([for graceful free(0)],[ac_cv_free_null],[
+ac_cv_free_null=no
+
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdlib.h>
+
+int main(int avc, char **av)
+{
+ free(0);
+ return 0;
+}
+]])],[ac_cv_free_null=yes],[ac_cv_free_null=no],[ac_cv_free_null=no])])
+
+if test $ac_cv_free_null = yes ; then
+AC_DEFINE([HAVE_FREE_NULL], 1, [
+Define this as 1 if your c library does not crash with free(0)])
+fi
+
dnl ======================================================================
dnl Socket features