Debian Codegraph @

src/xalloc.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 Moritz Grimm <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:412:9`!
18 # include "config.h"cxx . . $ `<file>/src/config.h`/
19 #endif
20
21 #include "compat.h"cxx . . $ `<file>/compat/compat.h`/
22
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "log.h"cxx . . $ `<file>/src/log.h`/
27 #include "xalloc.h"cxx . . $ `<file>/src/xalloc.h`/
28
29 void *
30 xmalloc_ccxx . . $ xmalloc_c(52bcf60a46ca15fc).(size_t size, const char *file, unsigned int line)
31 {
32 void *ret = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(size);
33
34 if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == ret) {
35 log_alertcxx . . $ log_alert(581fddd72a8db8fc).("%s[%u]: cannot allocate %zu bytes",
36 file, line, size);
37 exitcxx . . $ exit(3ca292c338df9bb3).(1);
38 }
39
40 return (ret);
41 }
42
43 void *
44 xcalloc_ccxx . . $ xcalloc_c(9afb910d5acaab39).(size_t nmemb, size_t size, const char *file, unsigned int line)
45 {
46 void *ret = calloccxx . . $ calloc(63a7bf2941bfcd7a).(nmemb, size);
47
48 if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == ret) {
49 log_alertcxx . . $ log_alert(581fddd72a8db8fc).("%s[%u]: cannot allocate %zu * %zu bytes",
50 file, line, nmemb, size);
51 exitcxx . . $ exit(3ca292c338df9bb3).(1);
52 }
53
54 return (ret);
55 }
56
57 void *
58 xreallocarray_ccxx . . $ xreallocarray_c(85fcaec808e0b3f).(void *ptr, size_t nmemb, size_t size, const char *file,
59 unsigned int line)
60 {
61 void *ret = reallocarraycxx . . $ reallocarray(dfa4a9ebc9436eff).(ptr, nmemb, size);
62
63 if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == ret) {
64 log_alertcxx . . $ log_alert(581fddd72a8db8fc).("%s[%u]: cannot allocate %zu * %zu bytes",
65 file, line, nmemb, size);
66 exitcxx . . $ exit(3ca292c338df9bb3).(1);
67 }
68
69 return (ret);
70 }
71
72 char *
73 xstrdup_ccxx . . $ xstrdup_c(daaded16d514aa0b).(const char *str, const char *file, unsigned int line)
74 {
75 char *ret = strdupcxx . . $ strdup(a8b8e32347182212).(str);
76
77 if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == ret) {
78 log_alertcxx . . $ log_alert(581fddd72a8db8fc).("%s[%u]: cannot allocate %zu bytes",
79 file, line, strlencxx . . $ strlen(751346f8406fd082).(str) + 1);
80 exitcxx . . $ exit(3ca292c338df9bb3).(1);
81 }
82
83 return (ret);
84 }
85
86 void
87 xfree_ccxx . . $ xfree_c(6359c8b694546919).(void *ptr, const char *file, unsigned int line)
88 {
89 (void)file;
90 (void)line;
91 freecxx . . $ free(5d22bdacc48458e8).(ptr);
92 }