/src/opensips/mem/thread_mem.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2026 OpenSIPS Solutions |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | */ |
20 | | |
21 | | /* |
22 | | * Thread memory wrappers mapped to libc allocators. |
23 | | */ |
24 | | |
25 | | #include <stdlib.h> |
26 | | |
27 | | #include "mem.h" |
28 | | |
29 | | #ifdef DBG_MALLOC |
30 | | void *thread_malloc_dbg(size_t size, const char *file, |
31 | | const char *function, unsigned int line) |
32 | | { |
33 | | (void)file; |
34 | | (void)function; |
35 | | (void)line; |
36 | | return malloc(size); |
37 | | } |
38 | | |
39 | | void *thread_realloc_dbg(void *ptr, size_t size, const char *file, |
40 | | const char *function, unsigned int line) |
41 | | { |
42 | | (void)file; |
43 | | (void)function; |
44 | | (void)line; |
45 | | return realloc(ptr, size); |
46 | | } |
47 | | |
48 | | void thread_free_dbg(void *ptr, const char *file, |
49 | | const char *function, unsigned int line) |
50 | | { |
51 | | (void)file; |
52 | | (void)function; |
53 | | (void)line; |
54 | | free(ptr); |
55 | | } |
56 | | #else |
57 | | void *thread_malloc(size_t size) |
58 | 0 | { |
59 | 0 | return malloc(size); |
60 | 0 | } |
61 | | |
62 | | void *thread_realloc(void *ptr, size_t size) |
63 | 0 | { |
64 | 0 | return realloc(ptr, size); |
65 | 0 | } |
66 | | |
67 | | void thread_free(void *ptr) |
68 | 0 | { |
69 | 0 | free(ptr); |
70 | 0 | } |
71 | | #endif |