-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
error_val.h
124 lines (107 loc) · 4.92 KB
/
error_val.h
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* global error codes for chunk allocation problems
*
* Copyright 2020 by Gray Watson
*
* This file is part of the dmalloc package.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Gray Watson not be used in advertising
* or publicity pertaining to distribution of the document or software
* without specific, written prior permission.
*
* Gray Watson makes no representations about the suitability of the
* software described herein for any purpose. It is provided "as is"
* without express or implied warranty.
*
* The author may be contacted via https://dmalloc.com/
*/
#ifndef __ERROR_VAL_H__
#define __ERROR_VAL_H__
/*
* Dmalloc error codes.
*
* NOTE: these are here instead of error.h because the dmalloc utility
* needs them as well as the dmalloc library.
*/
#define DMALLOC_ERROR_NONE 1 /* no error */
/* 2 is reserved for invalid error */
/* administrative errors */
#define DMALLOC_ERROR_BAD_SETUP 10 /* bad setup value */
#define DMALLOC_ERROR_IN_TWICE 11 /* in malloc domain twice */
/* 12 unused */
#define DMALLOC_ERROR_LOCK_NOT_CONFIG 13 /* thread locking not config */
/* pointer verification errors */
#define DMALLOC_ERROR_IS_NULL 20 /* pointer is NULL */
#define DMALLOC_ERROR_NOT_IN_HEAP 21 /* pointer is not in heap */
#define DMALLOC_ERROR_NOT_FOUND 22 /* pointer not-found */
#define DMALLOC_ERROR_IS_FOUND 23 /* found special pointer */
#define DMALLOC_ERROR_BAD_FILE 24 /* bad file-name */
#define DMALLOC_ERROR_BAD_LINE 25 /* bad line-number */
#define DMALLOC_ERROR_UNDER_FENCE 26 /* failed picket fence lower */
#define DMALLOC_ERROR_OVER_FENCE 27 /* failed picket fence upper */
#define DMALLOC_ERROR_WOULD_OVERWRITE 28 /* would overwrite fence */
/* 29 unused */
#define DMALLOC_ERROR_NOT_START_BLOCK 30 /* pointer not to start mem */
/* allocation errors */
#define DMALLOC_ERROR_BAD_SIZE 40 /* bad size value */
#define DMALLOC_ERROR_TOO_BIG 41 /* allocation too large */
/* 42 unused */
#define DMALLOC_ERROR_ALLOC_FAILED 43 /* could not get more space */
/* 44 unused */
#define DMALLOC_ERROR_OVER_LIMIT 45 /* over allocation limit */
/* free errors */
#define DMALLOC_ERROR_NOT_ON_BLOCK 60 /* not on block boundary */
#define DMALLOC_ERROR_ALREADY_FREE 61 /* already in free list */
/* 62-66 unused */
#define DMALLOC_ERROR_FREE_OVERWRITTEN 67 /* free space overwritten */
/* administrative errors */
#define DMALLOC_ERROR_ADMIN_LIST 70 /* list pnt out of bounds */
/* 71 unused */
#define DMALLOC_ERROR_ADDRESS_LIST 72 /* invalid address list */
#define DMALLOC_ERROR_SLOT_CORRUPT 73 /* memory slot corruption */
#define INVALID_ERROR "errno value is not valid"
typedef struct {
int es_error; /* error number */
char *es_string; /* associated string */
} error_str_t;
/* string error codes which apply to error codes in error_val.h */
static const error_str_t error_list[]
#ifdef __GNUC__
__attribute__ ((unused))
#endif
= {
{ DMALLOC_ERROR_NONE, "no error" },
/* administrative errors */
{ DMALLOC_ERROR_BAD_SETUP, "dmalloc initialization and setup failed" },
{ DMALLOC_ERROR_IN_TWICE, "dmalloc library has gone recursive" },
{ DMALLOC_ERROR_LOCK_NOT_CONFIG, "dmalloc thread locking has not been configured" },
/* pointer verification errors */
{ DMALLOC_ERROR_IS_NULL, "pointer is null" },
{ DMALLOC_ERROR_NOT_IN_HEAP, "pointer is not pointing to heap data space" },
{ DMALLOC_ERROR_NOT_FOUND, "cannot locate pointer in heap" },
{ DMALLOC_ERROR_IS_FOUND, "found pointer the user was looking for" },
{ DMALLOC_ERROR_BAD_FILE, "possibly bad .c filename pointer" },
{ DMALLOC_ERROR_BAD_LINE, "possibly bad .c file line-number" },
{ DMALLOC_ERROR_UNDER_FENCE, "failed UNDER picket-fence magic-number check"},
{ DMALLOC_ERROR_OVER_FENCE, "failed OVER picket-fence magic-number check"},
{ DMALLOC_ERROR_WOULD_OVERWRITE, "use of pointer would exceed allocation" },
{ DMALLOC_ERROR_NOT_START_BLOCK, "pointer is not to start of memory block" },
/* allocation errors */
{ DMALLOC_ERROR_BAD_SIZE, "invalid allocation size" },
{ DMALLOC_ERROR_TOO_BIG, "largest maximum allocation size exceeded" },
{ DMALLOC_ERROR_ALLOC_FAILED, "could not grow heap by allocating memory" },
{ DMALLOC_ERROR_OVER_LIMIT, "over user specified allocation limit" },
/* free errors */
{ DMALLOC_ERROR_NOT_ON_BLOCK, "pointer is not on block boundary" },
{ DMALLOC_ERROR_ALREADY_FREE, "tried to free previously freed pointer" },
{ DMALLOC_ERROR_FREE_OVERWRITTEN, "free space has been overwritten" },
/* administrative errors */
{ DMALLOC_ERROR_ADMIN_LIST, "dmalloc bad admin structure list" },
{ DMALLOC_ERROR_ADDRESS_LIST, "dmalloc internal address list corruption" },
{ DMALLOC_ERROR_SLOT_CORRUPT, "dmalloc internal memory slot corruption" },
{ 0 }
};
#endif /* ! __DMALLOC_ERROR_VAL_H__ */