malloc.h
1.69 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (C) 2015 James Hollister
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup native_cpu
*
* @brief Malloc header for use with native on OSX since there is no
* malloc.h file in the standard include path.
*
* @{
* @file
*
* @author James Hollister <jhollisterjr@gmail.com>
*/
#ifndef MALLOC_H
#define MALLOC_H
#include <stddef.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Allocate SIZE bytes of memory.
* @param[in] size Size of the block to allocate.
* @returns New memory block. NULL if failed to allocate.
*/
extern void *malloc (size_t size);
/**
* @brief Allocate NMEMB elements of SIZE bytes each, all initialized to 0.
* @param[in] nmemb Number of elements to be allocated.
* @param[in] size Size of the block to allocate.
* @returns New memory block. NULL if failed to allocate.
*/
extern void *calloc (size_t nmemb, size_t size);
/**
* @brief Re-allocate the previously allocated block in ptr, making the new
* block SIZE bytes long.
* @param[in] ptr Old memory block.
* @param[in] size Size of the new block to allocate.
* @returns New memory block. NULL if failed to allocate.
*/
extern void *realloc (void *ptr, size_t size);
/**
* @brief Free a block allocated by `malloc', `realloc' or `calloc'.
* @param[in] ptr Memory block that was allocated with 'malloc, 'realloc,
* or 'calloc'.
*/
extern void free (void *ptr);
#ifdef __cplusplus
}
#endif
#endif /* MALLOC_H */
/**
* @}
*/