Call dynstr_init on dynstr_free
This commit is contained in:
parent
9bf483cde2
commit
134ebfa751
2
dynstr.c
2
dynstr.c
|
@ -141,6 +141,6 @@ void dynstr_free(struct dynstr *const d)
|
||||||
if (d->str)
|
if (d->str)
|
||||||
{
|
{
|
||||||
free(d->str);
|
free(d->str);
|
||||||
memset(d, 0, sizeof *d);
|
dynstr_init(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,9 +131,11 @@ enum dynstr_err dynstr_dup(struct dynstr *dst, const struct dynstr *src);
|
||||||
/**
|
/**
|
||||||
* This function frees memory used by the dynamic string.
|
* This function frees memory used by the dynamic string.
|
||||||
* @param d Dynamic string to be freed.
|
* @param d Dynamic string to be freed.
|
||||||
* @attention Attempting to call this function on an uninitialized or empty
|
* @note This function does nothing on empty, initialized instances.
|
||||||
* instance is undefined behaviour.
|
* @attention Calling this function on an uninitialized instance leads to
|
||||||
* @attention Parameters inside the struct are reset once memory is freed.
|
* undefined behaviour.
|
||||||
|
* @attention Once memory is freed, @ref dynstr_init is called so it can be
|
||||||
|
* used again.
|
||||||
*/
|
*/
|
||||||
void dynstr_free(struct dynstr *d);
|
void dynstr_free(struct dynstr *d);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue