Memory management wrappers. More...
#include <stddef.h>
Go to the source code of this file.
Macros | |
#define | MAX(a, b) (((a) < (b)) ? (b) : (a)) |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
#define | CLAMP(val, lo, hi) MIN(hi, MAX(lo, val)) |
#define | ROUND_UP(NUM, STEP) ((((NUM) + (STEP) -1) / (STEP)) * (STEP)) |
#define | mutt_array_size(x) (sizeof(x) / sizeof((x)[0])) |
#define | FREE(x) mutt_mem_free(x) |
Functions | |
void * | mutt_mem_calloc (size_t nmemb, size_t size) |
Allocate zeroed memory on the heap. | |
void | mutt_mem_free (void *ptr) |
Release memory allocated on the heap. | |
void * | mutt_mem_malloc (size_t size) |
Allocate memory on the heap. | |
void | mutt_mem_realloc (void *ptr, size_t size) |
Resize a block of memory on the heap. | |
Memory management wrappers.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file memory.h.
#define ROUND_UP | ( | NUM, | |
STEP | |||
) | ((((NUM) + (STEP) -1) / (STEP)) * (STEP)) |
#define FREE | ( | x | ) | mutt_mem_free(x) |
void * mutt_mem_calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
Allocate zeroed memory on the heap.
nmemb | Number of blocks |
size | Size of blocks |
ptr | Memory on the heap |
The caller should call mutt_mem_free() to release the memory
Definition at line 51 of file memory.c.
void mutt_mem_free | ( | void * | ptr | ) |
void * mutt_mem_malloc | ( | size_t | size | ) |
Allocate memory on the heap.
size | Size of block to allocate |
ptr | Memory on the heap |
The caller should call mutt_mem_free() to release the memory
Definition at line 91 of file memory.c.
void mutt_mem_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Resize a block of memory on the heap.
ptr | Memory block to resize |
size | New size |
If the new size is zero, the block will be freed.
Definition at line 115 of file memory.c.