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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
Copyright (C) 2015-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/
/*
WARNING: This file was generated by the dkct program (see
http://dktools.sourceforge.net/ for details).
Changes you make here will be lost if dkct is run again!
You should modify the original source and run dkct on it.
Original source: dk4mema.ctr
*/
/** @file dk4mema.c The dk4mema module.
*/
#line 72 "dk4mema.ctr"
#include "dk4conf.h"
#include "dk4mema.h"
#include "dk4mem.h"
#include "dk4maodd.h"
#include "dk4const.h"
#if DK4_HAVE_ASSERT_H
#ifndef ASSERT_H_INCLUDED
#include <assert.h>
#define ASSERT_H_INCLUDED 1
#endif
#endif
void *
dk4mem_calloc_app(size_t elsize, size_t nelem, dk4_app_t *app)
{
dkChar elsb[64];
dkChar nelb[64];
void *back = NULL;
dk4_er_t er;
int res;
#if DK4_USE_ASSERT
assert(0 < elsize);
assert(0 < nelem);
#endif
dk4error_init(&er);
back = dk4mem_calloc(elsize, nelem, &er);
if (NULL == back) {
res = dk4ma_write_decimal_unsigned(
elsb, DK4_SIZEOF(elsb,dkChar), (dk4_um_t)elsize, 0, NULL
);
if (0 != res) {
res = dk4ma_write_decimal_unsigned(
nelb, DK4_SIZEOF(nelb,dkChar), (dk4_um_t)nelem, 0, NULL
);
}
switch (er.ec) {
case DK4_E_MATH_OVERFLOW: {
/* ERROR: Numeric overflow in size calculation */
if (0 != res) {
dk4app_log_base5(app,DK4_LL_ERROR,83,84,85,nelb,elsb);
} else {
dk4app_log_base1(app, DK4_LL_ERROR, 82);
}
} break;
case DK4_E_INVALID_ARGUMENTS: {
/* ERROR: Invalid sizes */
if (0 != res) {
dk4app_log_base5(app,DK4_LL_ERROR,87,88,89,nelb,elsb);
} else {
dk4app_log_base1(app, DK4_LL_ERROR, 86);
}
} break;
default: {
/* ERROR: Not enough memory */
if (0 != res) {
dk4app_log_base5(app,DK4_LL_ERROR,91,92,93,nelb,elsb);
} else {
dk4app_log_base1(app, DK4_LL_ERROR, 90);
}
} break;
}
}
return back;
}
|