8a5f06f |
Jamozed |
2022-02-09 20:04:50 |
0
|
// util/alloc.h, version 1.0.1 |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
1
|
// Memory allocation source file from libutil |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
2
|
// Copyright (C) 2021, Jakob Wakeling |
7f427d9 |
Jamozed |
2022-03-06 12:55:13 |
3
|
// MIT Licence |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
4
|
|
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
5
|
#include "alloc.h" |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
6
|
#include "error.h" |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
7
|
|
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
8
|
#include <stdlib.h> |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
9
|
|
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
10
|
void *xmalloc(UINT l) { |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
11
|
void *q = malloc(l); if (!q) { error(1, "%s", SERR); } return q; |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
12
|
} |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
13
|
|
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
14
|
void *xcalloc(UINT n, UINT l) { |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
15
|
void *q = calloc(n, l); if (!q) { error(1, "%s", SERR); } return q; |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
16
|
} |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
17
|
|
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
18
|
void *xrealloc(void *p, UINT l) { |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
19
|
void *q = realloc(p, l); if (!q) { error(1, "%s", SERR); } return q; |
f1897e7 |
Jamozed |
2021-12-08 14:00:19 |
20
|
} |
|
|
|
21
|
|