/[MITgcm]/MITgcm/tools/mpack-1.6/xmalloc.c
ViewVC logotype

Diff of /MITgcm/tools/mpack-1.6/xmalloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3 by jmc, Sat Feb 23 01:28:27 2008 UTC revision 1.4 by jmc, Sat Feb 23 03:30:03 2008 UTC
# Line 23  Line 23 
23   * SOFTWARE.   * SOFTWARE.
24   */   */
25  #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  
26  #include <string.h>  #include <string.h>
27    /* extern char *malloc(), *realloc(); */
28    
29  char *xmalloc (int size)  char *xmalloc (int size)
30  {  {
31      char *ret;      char *ret;
32    
33      if ((ret = malloc((unsigned) size)))      if (ret = (char *)malloc((unsigned) size))
34        return ret;        return ret;
35    
36      fprintf(stderr, "Memory exhausted\n");      fprintf(stderr, "Memory exhausted\n");
# Line 43  char *xrealloc (char *ptr, int size) Line 43  char *xrealloc (char *ptr, int size)
43      char *ret;      char *ret;
44    
45      /* xrealloc (NULL, size) behaves like xmalloc (size), as in ANSI C */      /* xrealloc (NULL, size) behaves like xmalloc (size), as in ANSI C */
46      if ((ret = !ptr ? malloc ((unsigned) size) : realloc (ptr, (unsigned) size)))      if (ret = !ptr ? ((char *)malloc ((unsigned) size)) : ((char *)realloc (ptr, (unsigned) size)))
47        return ret;        return ret;
48    
49      fprintf(stderr, "Memory exhausted\n");      fprintf(stderr, "Memory exhausted\n");

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22