Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not allow malloc(0) since that's not portable
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 18 May 2009 13:06:17 +0000 (13:06 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 18 May 2009 13:06:17 +0000 (13:06 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6290 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
include/xbt/sysdep.h
teshsuite/gras/datadesc/datadesc_usage.c

index 3ab6e6a..b43bef0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,7 +37,8 @@ SimGrid (3.4-svn) unstable; urgency=high
   * Also include strbuff from xbt.h public header
   * xbt_ex_display(): do not free the exception after displaying 
     This allows to do more with the given exception afterward.
   * Also include strbuff from xbt.h public header
   * xbt_ex_display(): do not free the exception after displaying 
     This allows to do more with the given exception afterward.
-    Users should call xbt_ex_free() themselves. 
+    Users should call xbt_ex_free() themselves.
+  * Do not allow malloc(0) since that's not portable
 
  -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr> 
 
 
  -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr> 
 
index 0d515ca..8b26453 100644 (file)
@@ -56,11 +56,17 @@ static XBT_INLINE char *xbt_strdup(const char *s) {
   } 
   return res;
 }
   } 
   return res;
 }
+extern void xbt_backtrace_display_current(void);
+
 /** @brief Like malloc, but xbt_die() on error 
     @hideinitializer */
 static XBT_INLINE void *xbt_malloc(unsigned int n){
   void *res;
 /** @brief Like malloc, but xbt_die() on error 
     @hideinitializer */
 static XBT_INLINE void *xbt_malloc(unsigned int n){
   void *res;
-/*  if (n==0) xbt_die("malloc(0) is not portable"); */
+  if (n==0) {
+     xbt_backtrace_display_current();
+     xbt_die("malloc(0) is not portable");
+  }
+   
   res=malloc(n);
   if (!res)
      xbt_die(bprintf("Memory allocation of %d bytes failed",n));
   res=malloc(n);
   if (!res)
      xbt_die(bprintf("Memory allocation of %d bytes failed",n));
@@ -71,7 +77,7 @@ static XBT_INLINE void *xbt_malloc(unsigned int n){
     @hideinitializer */
 static XBT_INLINE void *xbt_malloc0(unsigned int n) {
   void *res;
     @hideinitializer */
 static XBT_INLINE void *xbt_malloc0(unsigned int n) {
   void *res;
-/*  if (n==0) xbt_die("calloc(0) is not portable"); */
+  if (n==0) xbt_die("calloc(0) is not portable"); 
   res=calloc(n,1);
   if (!res)
      xbt_die(bprintf("Memory callocation of %d bytes failed",n));
   res=calloc(n,1);
   if (!res)
      xbt_die(bprintf("Memory callocation of %d bytes failed",n));
@@ -82,7 +88,7 @@ static XBT_INLINE void *xbt_malloc0(unsigned int n) {
     @hideinitializer */
 static XBT_INLINE void *xbt_realloc(void*p,unsigned int s){
   void *res=res;
     @hideinitializer */
 static XBT_INLINE void *xbt_realloc(void*p,unsigned int s){
   void *res=res;
-/*  if (s==0) xbt_die("realloc(0) is not portable"); */
+  if (s==0) xbt_die("realloc(0) is not portable"); 
   if (s) {
     if (p) {
       res=realloc(p,s);
   if (s) {
     if (p) {
       res=realloc(p,s);
index 51df175..eab24a2 100644 (file)
@@ -554,7 +554,7 @@ static void test_clause_empty(gras_socket_t sock, int direction) {
        i=xbt_new(Clause,1);
 
        i->num_lits = 0;
        i=xbt_new(Clause,1);
 
        i->num_lits = 0;
-       i->literals = xbt_new(int, 0);
+       i->literals = NULL;
        DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
        DEBUG1("created count=%d",i->num_lits);
 
        DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
        DEBUG1("created count=%d",i->num_lits);