mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
[fixup] remove unnecessarily complicated and unreliable asserts
This commit is contained in:
parent
4c9202d9f4
commit
ab0b262586
1 changed files with 2 additions and 14 deletions
|
|
@ -7,29 +7,17 @@
|
||||||
|
|
||||||
#define BUF_INITIAL_SIZE 256
|
#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
|
* Replace dst by src, src is invalid after this call
|
||||||
* but it may be reused when calling buf_init(src).
|
* but it may be reused when calling buf_init(src).
|
||||||
*
|
*
|
||||||
* dst must either have been initialized with buf_init()
|
* dst must either have been initialized with buf_init()
|
||||||
* or cleared out (e.g. created by znew() or on the stack
|
* or zeroed out (e.g. created by znew() or on the stack
|
||||||
* like struct buf foo = {0}).
|
* with something like struct buf foo = {0}).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
buf_replace_by(struct buf *dst, struct buf *src)
|
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);
|
free(dst->buf);
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue