APPFS
Advanced practical programming for scientists
Main Page
Data Structures
Files
File List
Globals
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
mshell.h
deallocate
void deallocate(void *p)
Free allocated memory.
Definition:
allocate.c:47
allocate.h
Wrapper for malloc.
allocate
void * allocate(int elems, int size)
Allocate memory.
Definition:
allocate.c:23
calloc
#define calloc(a, b)
Definition:
mshell.h:54
free
#define free(a)
Definition:
mshell.h:57
Generated on Sun Nov 16 2014 23:14:05 for APPFS by
1.8.6