[fixup] remove unnecessarily complicated and unreliable asserts

This commit is contained in:
Consolatis 2024-03-22 07:26:09 +01:00
parent 4c9202d9f4
commit ab0b262586

View file

@ -7,29 +7,17 @@
#define BUF_INITIAL_SIZE 256
#define BUF_CLEARED(s) ((s) && !(s)->buf && !(s)->alloc && !(s)->len)
#define BUF_INITIALIZED(s) ((s) && (s)->buf && (s)->alloc >= BUF_INITIAL_SIZE)
/*
* Replace dst by src, src is invalid after this call
* but it may be reused when calling buf_init(src).
*
* dst must either have been initialized with buf_init()
* or cleared out (e.g. created by znew() or on the stack
* like struct buf foo = {0}).
* or zeroed out (e.g. created by znew() or on the stack
* with something like struct buf foo = {0}).
*/
static void
buf_replace_by(struct buf *dst, struct buf *src)
{
assert(dst);
assert(BUF_INITIALIZED(src));
/*
* Tries to ensure that we don't accidentally try
* to free a random uninitialized dst->buf pointer
*/
assert(BUF_CLEARED(dst) || BUF_INITIALIZED(dst));
free(dst->buf);
*dst = *src;