scot_exceptions.c
1.08 KB
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
#include <stdio.h>
#include <scot/scot_exceptions.h>
#include <scot/exception.h>
#include <scot/memory.h>
#include <scot_common.h>
#include <scot/scot_types.h>
const char *scot_err_msg[] = {
N_("[SCOT]malloc failed"),
N_("[SCOT]NULL pointer not allowed"),
NULL
};
void *
exc_malloc (SIZE_T size)
{
return exc_malloc_fl (size, __FILE__, __LINE__);
}
void *
exc_malloc_fl (SIZE_T size, const char *file, int line)
{
void *a;
bindtextdomain (PACKAGE, LOCALEDIR);
a = SCOT_MEM_GET (size);
if (a == NULL)
THROW (exc_new (
EXC_ERROR,
file,
line,
MALLOC_ERR,
D_(scot_err_msg [MALLOC_ERR])));
return a;
}
void
check_null (const void *var)
{
check_null_fl (var, __FILE__, __LINE__);
}
void
check_null_fl (const void *var, const char* file, int line)
{
bindtextdomain (PACKAGE, LOCALEDIR);
if (var == NULL)
THROW (exc_new (
EXC_ERROR,
file,
line,
NULL_PTR_ERR,
D_(scot_err_msg [NULL_PTR_ERR])));
}