forked from ascot4fusion/ascot5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libascot_mem.c
50 lines (45 loc) · 1.14 KB
/
libascot_mem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @file libascot_mem.c
* @brief Provides memory de/allocation routines for the libascot
*/
#include <stdlib.h>
#include "libascot_mem.h"
#include "particle.h"
/**
* @brief A routine to allocate an array of input particles
*
* @param nmrk number of markers for which space is allocated
*
* @return pointer to the allocated array
*/
input_particle* libascot_allocate_input_particles(int nmrk) {
return (input_particle*) malloc(nmrk * sizeof(input_particle) );
}
/**
* @brief A routine to allocate an array of particle states
*
* @param nmrk number of markers for which space is allocated
*
* @return pointer to the allocated array
*/
particle_state* libascot_allocate_particle_states(int nmrk) {
return (particle_state*) malloc(nmrk * sizeof(particle_state) );
}
/**
* @brief A routine to allocate an array of reals
*
* @param size size of the array
*
* @return pointer to the allocated array
*/
real* libascot_allocate_reals(size_t size) {
return ( real* ) malloc( size * sizeof(real) );
}
/**
* @brief A wrapper to C stdlib free()
*
* @param arr array to be freed
*/
void libascot_deallocate(void *arr) {
free(arr);
}