Context algorithm
Semi-predictive context algorithm implementation
 All Data Structures Files Functions Variables Typedefs Macros Pages
spacedef.h File Reference
#include <string.h>
#include "types.h"

Go to the source code of this file.

Macros

#define REALLOCSPACE(S, T, N)   (T *) realloc(S,sizeof(T) * (size_t) (N))
 Resizes a block of memory. More...
 
#define REALLOC(V, S, T, N)
 Resizes a block of memory and prints an error message if necessary. More...
 
#define FREE(P)
 Frees a block of memory and makes the pointer NULL. More...
 
#define CALLOC(S, T, N)
 Allocs a new block of memory and sets all its bits to zero. More...
 
#define MALLOC(S, T, N)
 

Macro Definition Documentation

#define CALLOC (   S,
  T,
 
)
Value:
S = calloc(sizeof(T), N);\
if ((S) == NULL) {\
fprintf(stderr,"file %s, line %lu: calloc(%lu) failed\n",\
__FILE__,(Showuint) __LINE__,\
(Showuint) (sizeof(T) * (size_t) (N)));\
exit(EXIT_FAILURE);\
}
unsigned long Showuint
Type of unsigned integer in printf.
Definition: types.h:84

Allocs a new block of memory and sets all its bits to zero.

Parameters
[out]Spointer to the new allocated memory.
[in]Ttype of the objects that will be stored in this memory area.
[in]Nnumber of objects of type T that will be possible to store in the new memory.

Definition at line 72 of file spacedef.h.

#define FREE (   P)
Value:
if((P) != NULL)\
{\
free(P);\
P = NULL;\
}

Frees a block of memory and makes the pointer NULL.

Parameters
[in]Ppointer to the memory to free.

Definition at line 58 of file spacedef.h.

#define MALLOC (   S,
  T,
 
)
Value:
S = malloc(sizeof(T) * N);\
if ((S) == NULL) {\
fprintf(stderr,"file %s, line %lu: calloc(%lu) failed\n",\
__FILE__,(Showuint) __LINE__,\
(Showuint) (sizeof(T) * (size_t) (N)));\
exit(EXIT_FAILURE);\
}
unsigned long Showuint
Type of unsigned integer in printf.
Definition: types.h:84

Definition at line 81 of file spacedef.h.

#define REALLOC (   V,
  S,
  T,
 
)
Value:
V = REALLOCSPACE(S,T,N);\
if((V) == NULL)\
{\
fprintf(stderr,"file %s, line %lu: realloc(%lu) failed\n",\
__FILE__,(Showuint) __LINE__,\
(Showuint) (sizeof(T) * (size_t) (N)));\
exit(EXIT_FAILURE);\
}
unsigned long Showuint
Type of unsigned integer in printf.
Definition: types.h:84
#define REALLOCSPACE(S, T, N)
Resizes a block of memory.
Definition: spacedef.h:32

Resizes a block of memory and prints an error message if necessary.

Parameters
[out]Vpointer that will point to the resized memory.
[in]Spointer to the memory to resize.
[in]Ttype of the objects that are stored in the memory to resize.
[in]Nnumber of objects of type T that will be possible to store in the resized memory.

Definition at line 43 of file spacedef.h.

#define REALLOCSPACE (   S,
  T,
 
)    (T *) realloc(S,sizeof(T) * (size_t) (N))

Resizes a block of memory.

Parameters
[in]Spointer to the memory to resize.
[in]Ttype of the objects that are stored in the memory to resize.
[in]Nnumber of objects of type T that will be possible to store in the resized memory.
Returns
a pointer to the resized memory.

Definition at line 32 of file spacedef.h.