2
0

Ensure all read utilities yield constant string pointers for safety.

This commit is contained in:
Maarten Billemont
2018-09-22 09:47:11 -04:00
parent af768329a3
commit 48d4668575
4 changed files with 15 additions and 11 deletions

View File

@@ -144,6 +144,10 @@ bool __mpw_free_string(
({ __typeof__(strings) _s = strings; const char *__s = *_s; (void)__s; __mpw_free_strings( (char **)_s, __VA_ARGS__ ); })
bool __mpw_free_strings(
char **strings, ...);
/** Free a string after zero'ing its contents, then set the reference to the replacement string.
* The replacement string is generated before the original is freed; it may be a derivative of the original. */
#define mpw_replace_string(string, replacement) \
do { const char *replacement_ = replacement; mpw_free_string( &string ); string = replacement_; } while (0)
#ifdef _MSC_VER
#undef mpw_realloc
#define mpw_realloc(buffer, bufferSize, deltaSize) \