summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/malloc-wrapper.c
diff options
context:
space:
mode:
authortb <>2024-03-02 11:28:46 +0000
committertb <>2024-03-02 11:28:46 +0000
commit9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34 (patch)
treef40142fa94b70538607eebd6e277749aa7bb40c1 /src/lib/libcrypto/malloc-wrapper.c
parente26a003ae69c592a266ff1b2331d6206111a56db (diff)
downloadopenbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.tar.gz
openbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.tar.bz2
openbsd-9b9fc000d4d482c0c3086b0e54b4c1a88c76ee34.zip
Remove a bunch of CRYPTO memory API
This was neutered early on in the fork and has been rotting ever since. Some parts of the API are still used, but it's easier to clean up when most of the mess is gone. ok jsing
Diffstat (limited to 'src/lib/libcrypto/malloc-wrapper.c')
-rw-r--r--src/lib/libcrypto/malloc-wrapper.c150
1 files changed, 1 insertions, 149 deletions
diff --git a/src/lib/libcrypto/malloc-wrapper.c b/src/lib/libcrypto/malloc-wrapper.c
index 4d57f00b23..e13cc23373 100644
--- a/src/lib/libcrypto/malloc-wrapper.c
+++ b/src/lib/libcrypto/malloc-wrapper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc-wrapper.c,v 1.8 2023/07/08 08:28:23 beck Exp $ */ 1/* $OpenBSD: malloc-wrapper.c,v 1.9 2024/03/02 11:28:46 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Bob Beck 3 * Copyright (c) 2014 Bob Beck
4 * 4 *
@@ -36,111 +36,6 @@ CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
36} 36}
37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); 37LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions);
38 38
39int
40CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
41{
42 return 0;
43}
44LCRYPTO_ALIAS(CRYPTO_set_locked_mem_functions);
45
46int
47CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
48 void (*f)(void *))
49{
50 return 0;
51}
52LCRYPTO_ALIAS(CRYPTO_set_locked_mem_ex_functions);
53
54int
55CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int),
56 void (*r)(void *, void *, int, const char *, int, int),
57 void (*f)(void *, int), void (*so)(long), long (*go)(void))
58{
59 return 0;
60}
61LCRYPTO_ALIAS(CRYPTO_set_mem_debug_functions);
62
63
64void
65CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
66 void (**f)(void *))
67{
68 if (m != NULL)
69 *m = malloc;
70 if (r != NULL)
71 *r = realloc;
72 if (f != NULL)
73 *f = free;
74}
75LCRYPTO_ALIAS(CRYPTO_get_mem_functions);
76
77void
78CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
79 void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
80{
81 if (m != NULL)
82 *m = NULL;
83 if (r != NULL)
84 *r = NULL;
85 if (f != NULL)
86 *f = free;
87}
88LCRYPTO_ALIAS(CRYPTO_get_mem_ex_functions);
89
90void
91CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
92{
93 if (m != NULL)
94 *m = malloc;
95 if (f != NULL)
96 *f = free;
97}
98LCRYPTO_ALIAS(CRYPTO_get_locked_mem_functions);
99
100void
101CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
102 void (**f)(void *))
103{
104 if (m != NULL)
105 *m = NULL;
106 if (f != NULL)
107 *f = free;
108}
109LCRYPTO_ALIAS(CRYPTO_get_locked_mem_ex_functions);
110
111void
112CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
113 void (**r)(void *, void *, int, const char *, int, int),
114 void (**f)(void *, int), void (**so)(long), long (**go)(void))
115{
116 if (m != NULL)
117 *m = NULL;
118 if (r != NULL)
119 *r = NULL;
120 if (f != NULL)
121 *f = NULL;
122 if (so != NULL)
123 *so = NULL;
124 if (go != NULL)
125 *go = NULL;
126}
127LCRYPTO_ALIAS(CRYPTO_get_mem_debug_functions);
128
129
130void *
131CRYPTO_malloc_locked(int num, const char *file, int line)
132{
133 if (num <= 0)
134 return NULL;
135 return malloc(num);
136}
137
138void
139CRYPTO_free_locked(void *ptr)
140{
141 free(ptr);
142}
143
144void * 39void *
145CRYPTO_malloc(int num, const char *file, int line) 40CRYPTO_malloc(int num, const char *file, int line)
146{ 41{
@@ -155,51 +50,8 @@ CRYPTO_strdup(const char *str, const char *file, int line)
155 return strdup(str); 50 return strdup(str);
156} 51}
157 52
158void *
159CRYPTO_realloc(void *ptr, int num, const char *file, int line)
160{
161 if (num <= 0)
162 return NULL;
163 return realloc(ptr, num);
164}
165
166void *
167CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file,
168 int line)
169{
170 if (num <= 0)
171 return NULL;
172 /* Original does not support shrinking. */
173 if (num < old_len)
174 return NULL;
175 return recallocarray(ptr, old_len, num, 1);
176}
177LCRYPTO_ALIAS(CRYPTO_realloc_clean);
178
179void 53void
180CRYPTO_free(void *ptr) 54CRYPTO_free(void *ptr)
181{ 55{
182 free(ptr); 56 free(ptr);
183} 57}
184
185void *
186CRYPTO_remalloc(void *a, int num, const char *file, int line)
187{
188 free(a);
189 return malloc(num);
190}
191LCRYPTO_ALIAS(CRYPTO_remalloc);
192
193void
194CRYPTO_set_mem_debug_options(long bits)
195{
196 return;
197}
198LCRYPTO_ALIAS(CRYPTO_set_mem_debug_options);
199
200long
201CRYPTO_get_mem_debug_options(void)
202{
203 return 0;
204}
205LCRYPTO_ALIAS(CRYPTO_get_mem_debug_options);