SVF
Functions | Variables
safe_mem.c File Reference
#include <stdio.h>
#include "CUDD/util.h"

Go to the source code of this file.

Functions

char * MMalloc (long)
 
void MMout_of_memory (long)
 
char * MMrealloc (char *, long)
 
void MMfree (char *obj)
 

Variables

void(* MMoutOfMemory )(long) = MMout_of_memory
 

Function Documentation

◆ MMalloc()

char* MMalloc ( long  size)

Definition at line 51 of file safe_mem.c.

52 {
53  char *p;
54 
55 #ifdef IBMPC
56  if (size > 65000L) {
57  if (MMoutOfMemory != (void (*)(long)) 0 ) (*MMoutOfMemory)(size);
58  return NIL(char);
59  }
60 #endif
61  if (size == 0) size = sizeof(long);
62  if ((p = (char *) malloc((unsigned long) size)) == NIL(char)) {
63  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
64  return NIL(char);
65  }
66  return p;
67 }
void(* MMoutOfMemory)(long)
Definition: safe_mem.c:32
#define NIL(type)
Definition: util.h:44
VOID_OR_CHAR * malloc()

◆ MMfree()

void MMfree ( char *  obj)

Definition at line 92 of file safe_mem.c.

93 {
94  if (obj != 0) {
95  free(obj);
96  }
97 }
VOID_OR_INT free(void *)

◆ MMout_of_memory()

void MMout_of_memory ( long  size)

Definition at line 41 of file safe_mem.c.

42 {
43  (void) fflush(stdout);
44  (void) fprintf(stderr, "\nout of memory allocating %lu bytes\n",
45  (unsigned long) size);
46  exit(1);
47 }
VOID_OR_INT exit()

◆ MMrealloc()

char* MMrealloc ( char *  obj,
long  size 
)

Definition at line 71 of file safe_mem.c.

72 {
73  char *p;
74 
75 #ifdef IBMPC
76  if (size > 65000L) {
77  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
78  return NIL(char);
79  }
80 #endif
81  if (obj == NIL(char)) return MMalloc(size);
82  if (size <= 0) size = sizeof(long);
83  if ((p = (char *) realloc(obj, (unsigned long) size)) == NIL(char)) {
84  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
85  return NIL(char);
86  }
87  return p;
88 }
void(* MMoutOfMemory)(long)
Definition: safe_mem.c:32
#define NIL(type)
Definition: util.h:44
VOID_OR_CHAR * realloc()
char * MMalloc(long)
Definition: safe_mem.c:51

Variable Documentation

◆ MMoutOfMemory

void(* MMoutOfMemory) (long) = MMout_of_memory

Definition at line 32 of file safe_mem.c.