Mercurial > hg > th-libs
annotate th_util.c @ 462:a90fe2c4c636
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 15:49:16 +0300 |
parents | 85fa3d333556 |
children | b92b18500bf9 |
rev | line source |
---|---|
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Generic utility-functions, macros and defaults |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
144 | 4 * (C) Copyright 2002-2015 Tecnic Software productions (TNSP) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "th_util.h" |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
96 | 10 #include <errno.h> |
11 | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 |
4
67f4a4233372
Move defaults to header file.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
13 /* Default settings |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 */ |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
15 static BOOL th_initialized = FALSE; |
60 | 16 int th_verbosityLevel = 2; |
17 char *th_prog_name = NULL, | |
18 *th_prog_desc = NULL, | |
19 *th_prog_version = NULL, | |
20 *th_prog_author = NULL, | |
21 *th_prog_license = NULL; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 /* Initialize th_util-library and global variables |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 */ |
60 | 26 void th_init(char *name, char *desc, char *version, |
27 char *author, char *license) | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 { |
60 | 29 th_prog_name = name; |
30 th_prog_desc = desc; | |
31 th_prog_version = version; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
60 | 33 if (author) |
34 th_prog_author = author; | |
10 | 35 else |
36 th_prog_author = TH_PROG_AUTHOR; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 |
60 | 38 if (license) |
39 th_prog_license = license; | |
10 | 40 else |
41 th_prog_license = TH_PROG_LICENSE; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
43 th_initialized = TRUE; |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 |
64 | 47 void th_print_banner(FILE *outFile, const char *name, const char *usage) |
45
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
48 { |
177
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
49 fprintf(outFile, "\n%s", th_prog_name); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
50 if (th_prog_version != NULL) |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
51 fprintf(outFile, " v%s", th_prog_version); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
52 if (th_prog_desc != NULL) |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
53 fprintf(outFile, " (%s)", th_prog_desc); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
54 fprintf(outFile, "\n"); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
55 |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
56 if (th_prog_author != NULL) |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
57 fprintf(outFile, "%s\n", th_prog_author); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
58 |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
59 if (th_prog_license != NULL) |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
60 fprintf(outFile, "%s\n", th_prog_license); |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
61 |
2b07e452fd78
Adjust program banner printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
162
diff
changeset
|
62 fprintf(outFile, "Usage: %s %s\n", name, usage); |
45
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
63 } |
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
64 |
e031a062b731
Separate program "banner" printing from th_args_help() to th_print_banner().
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
65 |
143 | 66 int th_term_width() |
67 { | |
68 char *var = getenv("COLUMNS"); | |
69 int res = (var != NULL) ? atoi(var) : 80; | |
70 if (res < 5) res = 80; | |
71 return res; | |
72 } | |
73 | |
74 | |
75 int th_term_height() | |
76 { | |
77 char *var = getenv("LINESS"); | |
78 int res = (var != NULL) ? atoi(var) : 25; | |
79 if (res < 1) res = 1; | |
80 return res; | |
81 } | |
82 | |
83 | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 /* Print formatted error, warning and information messages |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 * TODO: Implement th_vfprintf() and friends? |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 */ |
11 | 87 void THERR_V(const char *fmt, va_list ap) |
88 { | |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
89 assert(th_initialized == TRUE); |
11 | 90 |
91 fprintf(stderr, "%s: ", th_prog_name); | |
92 vfprintf(stderr, fmt, ap); | |
93 } | |
94 | |
95 | |
96 void THMSG_V(int level, const char *fmt, va_list ap) | |
97 { | |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
98 assert(th_initialized == TRUE); |
11 | 99 |
48 | 100 if (th_verbosityLevel >= level) |
101 { | |
11 | 102 fprintf(stderr, "%s: ", th_prog_name); |
103 vfprintf(stderr, fmt, ap); | |
104 } | |
105 } | |
106 | |
107 | |
108 void THPRINT_V(int level, const char *fmt, va_list ap) | |
109 { | |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
110 assert(th_initialized == TRUE); |
11 | 111 |
48 | 112 if (th_verbosityLevel >= level) |
113 { | |
11 | 114 vfprintf(stderr, fmt, ap); |
115 } | |
116 } | |
117 | |
118 | |
119 void THERR(const char *fmt, ...) | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 { |
10 | 121 va_list ap; |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
122 assert(th_initialized == TRUE); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
11 | 124 va_start(ap, fmt); |
125 THERR_V(fmt, ap); | |
10 | 126 va_end(ap); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
11 | 130 void THMSG(int level, const char *fmt, ...) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 { |
10 | 132 va_list ap; |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
133 assert(th_initialized == TRUE); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 |
11 | 135 va_start(ap, fmt); |
136 THMSG_V(level, fmt, ap); | |
137 va_end(ap); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
11 | 141 void THPRINT(int level, const char *fmt, ...) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 { |
10 | 143 va_list ap; |
457
85fa3d333556
Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
144 assert(th_initialized == TRUE); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 |
11 | 146 va_start(ap, fmt); |
147 THPRINT_V(level, fmt, ap); | |
148 va_end(ap); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 |
96 | 152 /* Error handling |
153 */ | |
101
a8f732601fdc
Rename th_get_errno() to th_get_error(), it's more appropriate since it does
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
154 int th_get_error() |
96 | 155 { |
156 return TH_SYSTEM_ERRORS + errno; | |
157 } | |
158 | |
159 | |
99 | 160 int th_errno_to_error(int error) |
161 { | |
162 return TH_SYSTEM_ERRORS + error; | |
163 } | |
164 | |
165 | |
96 | 166 const char *th_error_str(int error) |
167 { | |
168 if (error >= TH_SYSTEM_ERRORS) | |
169 return strerror(error - TH_SYSTEM_ERRORS); | |
441
2991e6b52d95
Get rid of trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
170 |
96 | 171 switch (error) |
172 { | |
173 case THERR_OK: return "No error"; | |
174 case THERR_FOPEN: return "File open error"; | |
175 case THERR_FREAD: return "Read error"; | |
176 case THERR_FWRITE: return "Write error"; | |
177 case THERR_FSEEK: return "Seek error"; | |
178 case THERR_NOT_FOUND: return "Resource not found"; | |
179 | |
180 case THERR_INVALID_DATA: return "Invalid data"; | |
181 case THERR_MALLOC: return "Memory allocation failure"; | |
182 case THERR_ALREADY_INIT: return "Already initialized"; | |
183 case THERR_INIT_FAIL: return "Initialization failed"; | |
184 case THERR_INVALID_ARGS: return "Invalid arguments"; | |
185 | |
186 case THERR_NULLPTR: return "NULL pointer"; | |
187 case THERR_NOT_SUPPORTED: return "Operation not supported"; | |
188 case THERR_OUT_OF_DATA: return "Out of data"; | |
189 case THERR_EXTRA_DATA: return "Extra data"; | |
190 case THERR_BOUNDS: return "Bounds check failed"; | |
191 | |
192 case THERR_TIMED_OUT: return "Operation timed out"; | |
441
2991e6b52d95
Get rid of trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
193 |
96 | 194 case THERR_AUTH_FAILED: return "Authentication failed"; |
195 | |
196 default: return "Unknown error"; | |
197 } | |
198 } | |
199 | |
200 | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
201 /* Memory handling routines |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 */ |
462 | 203 void *th_malloc(size_t len) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 { |
462 | 205 return malloc(len); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 |
462 | 209 void *th_malloc0(size_t len) |
68
29f9651465c6
Added a new memory allocator function, th_malloc0(size), which is the same as calloc(1, size).
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
210 { |
462 | 211 return calloc(1, len); |
68
29f9651465c6
Added a new memory allocator function, th_malloc0(size), which is the same as calloc(1, size).
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
212 } |
29f9651465c6
Added a new memory allocator function, th_malloc0(size), which is the same as calloc(1, size).
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
213 |
29f9651465c6
Added a new memory allocator function, th_malloc0(size), which is the same as calloc(1, size).
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
214 |
462 | 215 void *th_calloc(size_t n, size_t len) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 { |
462 | 217 return calloc(n, len); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
220 |
462 | 221 void *th_realloc(void *ptr, size_t len) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
222 { |
462 | 223 return realloc(ptr, len); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 |
194
87dac812cac4
Define some argument identifiers in function prototypes and rename some arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
227 void th_free(void *ptr) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 { |
10 | 229 /* Check for NULL pointers for portability due to some libc |
230 * implementations not handling free(NULL) too well. | |
231 */ | |
194
87dac812cac4
Define some argument identifiers in function prototypes and rename some arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
232 if (ptr != NULL) free(ptr); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 |
197
88986d0b56ef
Rename th_free_r() to th_free_r_real() and #define a macro wrapper for
Matti Hamalainen <ccr@tnsp.org>
parents:
195
diff
changeset
|
236 void th_free_r_real(void **ptr) |
192
7d25d43a3ce2
Add new function th_free_r(void **ptr) that calls th_free(*ptr) and sets *ptr to NULL.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
237 { |
195 | 238 if (ptr != NULL) |
192
7d25d43a3ce2
Add new function th_free_r(void **ptr) that calls th_free(*ptr) and sets *ptr to NULL.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
239 { |
194
87dac812cac4
Define some argument identifiers in function prototypes and rename some arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
240 th_free(*ptr); |
87dac812cac4
Define some argument identifiers in function prototypes and rename some arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
241 *ptr = NULL; |
192
7d25d43a3ce2
Add new function th_free_r(void **ptr) that calls th_free(*ptr) and sets *ptr to NULL.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
242 } |
7d25d43a3ce2
Add new function th_free_r(void **ptr) that calls th_free(*ptr) and sets *ptr to NULL.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
243 } |