APPFS
Advanced practical programming for scientists
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
allocate.c
Go to the documentation of this file.
1 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <assert.h>
9 #include "allocate.h"
10 
11 #include "mshell.h"
12 
23 void* allocate(int elems, int size)
24 {
25  void* p;
26 
27  assert(elems > 0);
28  assert(size > 0);
29 
30  if (NULL == (p = calloc((size_t)elems, (size_t)size)))
31  {
32  perror("allocate");
33  exit(EXIT_FAILURE);
34  }
35  assert(p != NULL);
36 
37  return p;
38 }
39 
47 void deallocate(void* p)
48 {
49  assert(p != NULL);
50 
51  free(p);
52 }
53 
54 
55 
void deallocate(void *p)
Free allocated memory.
Definition: allocate.c:47
Wrapper for malloc.
void * allocate(int elems, int size)
Allocate memory.
Definition: allocate.c:23
#define calloc(a, b)
Definition: mshell.h:54
#define free(a)
Definition: mshell.h:57