NeoMutt  2024-10-02-34-g9dd811
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1
23#ifndef MUTT_MUTT_MEMORY_H
24#define MUTT_MUTT_MEMORY_H
25
26#include <stddef.h>
27
28#undef MAX
29#undef MIN
30#undef CLAMP
31#define MAX(a, b) (((a) < (b)) ? (b) : (a))
32#define MIN(a, b) (((a) < (b)) ? (a) : (b))
33#define CLAMP(val, lo, hi) MIN(hi, MAX(lo, val))
34
35#undef ROUND_UP
36#define ROUND_UP(NUM, STEP) ((((NUM) + (STEP) -1) / (STEP)) * (STEP))
37
38#define mutt_array_size(x) (sizeof(x) / sizeof((x)[0]))
39
40void *mutt_mem_calloc(size_t nmemb, size_t size);
41void mutt_mem_free(void *ptr);
42void *mutt_mem_malloc(size_t size);
43void mutt_mem_realloc(void *ptr, size_t size);
44
45#define FREE(x) mutt_mem_free(x)
46
47#endif /* MUTT_MUTT_MEMORY_H */
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
void mutt_mem_free(void *ptr)
Release memory allocated on the heap.
Definition: memory.c:69
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:91
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:115