Memory management wrappers. More...
#include "config.h"
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "memory.h"
#include "exit.h"
#include "logging2.h"
Go to the source code of this file.
Functions | |
static void * | reallocarray (void *p, size_t n, size_t size) |
reallocarray(3) implementation | |
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_mallocarray (size_t nmemb, size_t size) |
Allocate memory on the heap (array version) | |
void | mutt_mem_realloc (void *pptr, size_t size) |
Resize a block of memory on the heap. | |
void | mutt_mem_reallocarray (void *pptr, size_t nmemb, size_t size) |
Resize a block of memory on the heap (array version) | |
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.c.
|
static |
reallocarray(3) implementation
p | Address of memory block to resize |
n | Number of elements |
size | Size of element |
See reallocarray(3) for the documentation of this function. We need to implement it because MacOS is cruft from another century and doesn't have this fundamental API. We'll remove it once all the systems we support have it.
Definition at line 53 of file memory.c.
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 76 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 113 of file memory.c.
void * mutt_mem_mallocarray | ( | size_t | nmemb, |
size_t | size | ||
) |
Allocate memory on the heap (array version)
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 129 of file memory.c.
void mutt_mem_realloc | ( | void * | pptr, |
size_t | size | ||
) |
Resize a block of memory on the heap.
pptr | Address of pointer to memory block to resize |
size | New size |
If the new size is zero, the block will be freed.
Definition at line 146 of file memory.c.
void mutt_mem_reallocarray | ( | void * | pptr, |
size_t | nmemb, | ||
size_t | size | ||
) |
Resize a block of memory on the heap (array version)
pptr | Address of pointer to memory block to resize |
nmemb | Number of blocks |
size | Size of blocks |
If the new size is zero, the block will be freed.
Definition at line 162 of file memory.c.