mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
common/mem.h: introduce xstrdup_replace()
This commit is contained in:
parent
6754801052
commit
a4204d3335
1 changed files with 8 additions and 0 deletions
|
|
@ -44,6 +44,14 @@ void *xrealloc(void *ptr, size_t size);
|
||||||
*/
|
*/
|
||||||
char *xstrdup(const char *str);
|
char *xstrdup(const char *str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same as ptr = xstrdup(str) but free
|
||||||
|
* <ptr> before assigning the result.
|
||||||
|
*/
|
||||||
|
#define xstrdup_replace(ptr, str) do { \
|
||||||
|
free(ptr); (ptr) = xstrdup(str); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Frees memory pointed to by <ptr> and sets <ptr> to NULL.
|
* Frees memory pointed to by <ptr> and sets <ptr> to NULL.
|
||||||
* Does nothing if <ptr> is already NULL.
|
* Does nothing if <ptr> is already NULL.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue