myMPD
Internal API documentation
Loading...
Searching...
No Matches
mem.h
1
/*
2
SPDX-License-Identifier: GPL-3.0-or-later
3
myMPD (c) 2018-2025 Juergen Mang <mail@jcgames.de>
4
https://github.com/jcorporation/mympd
5
*/
6
7
#ifndef MYMPD_MEM_H
8
#define MYMPD_MEM_H
9
10
#include "src/lib/log.h"
11
12
#include <stdlib.h>
13
19
__attribute__((malloc))
20
static
inline
void
*malloc_assert(
size_t
size) {
21
void
*p = malloc(size);
22
if
(p == NULL) {
23
MYMPD_LOG_EMERG(NULL,
"Failure allocating %lu bytes of memory"
, (
unsigned
long
) size);
24
abort();
25
}
26
return
p;
27
}
28
35
__attribute__((malloc))
36
static
inline
void
*realloc_assert(
void
*ptr,
size_t
size) {
37
void
*p = realloc(ptr, size);
38
if
(p == NULL) {
39
MYMPD_LOG_EMERG(NULL,
"Failure allocating %lu bytes of memory"
, (
unsigned
long
) size);
40
abort();
41
}
42
return
p;
43
}
44
49
#define FREE_PTR(PTR) do { \
50
if (PTR != NULL) \
51
free(PTR); \
52
PTR = NULL; \
53
} while (0)
54
55
#endif
src
lib
mem.h
Generated by
1.9.8