Changeset 505 for trunk/matml

Show
Ignore:
Timestamp:
11/30/2009 04:18:53 PM (2 years ago)
Author:
powell
Message:

Bug fix: if numsegs=0, don't realloc thesegs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/matml/src/ternary/spinodal.c

    r483 r505  
    452452    { 
    453453      spinreturn->compos = 2; 
    454       if (!(thesegs = (int *) realloc 
    455             (thesegs, 2*numsegs*sizeof (int)))) 
    456         { free (thenewpoints); free (thesegs); return 1; } 
     454      if (numsegs) 
     455        { 
     456          if (!(thesegs = (int *) realloc 
     457                (thesegs, 2*numsegs*sizeof (int)))) 
     458            { free (thenewpoints); free (thesegs); return 1; } 
     459        } 
     460      else 
     461        { 
     462          free (thesegs); 
     463          thesegs = NULL; 
     464        } 
    457465      spinreturn->edges = thesegs; 
    458466#ifdef DEBUG