~lattis/muon

ref: 49a50d56c57dfdf470b4bcbffc16bc5ec92dcb4e muon/src/platform/mem.c -rw-r--r-- 760 bytes
49a50d56Stone Tickle support comma seperated option array 9 months ago
                                                                                
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
#include "posix.h"

#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#include "error.h"
#include "platform/mem.h"

void *
z_calloc(size_t nmemb, size_t size)
{
	assert(size);
	void *ret;
	ret = calloc(nmemb, size);

	if (!ret) {
		error_unrecoverable("calloc failed: %s", strerror(errno));
	}
	return ret;
}

void *
z_malloc(size_t size)
{
	assert(size);
	void *ret;
	ret = malloc(size);

	if (!ret) {
		error_unrecoverable("malloc failed: %s", strerror(errno));
	}

	return ret;
}

void *
z_realloc(void *ptr, size_t size)
{
	assert(size);
	void *ret;
	ret = realloc(ptr, size);

	if (!ret) {
		error_unrecoverable("realloc failed: %s", strerror(errno));
	}

	return ret;
}

void
z_free(void *ptr)
{
	assert(ptr);
	free(ptr);
}