Skip to content

Commit 026f8c1

Browse files
committed
Add strb_init() function.
It allows initializing at runtime an strb. This can't always be done at compile-time, for instance if it is dynamically allocated.
1 parent d80fc0e commit 026f8c1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/util/strb.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ static inline int strb_error(strb *sb) {
7777
return sb->l == (size_t)-1;
7878
}
7979

80+
/*
81+
* Initialize at runtime an strb.
82+
*/
83+
84+
static inline void strb_init(strb* sb){
85+
const strb s = STRB_STATIC_INIT;
86+
*sb = s;
87+
}
88+
8089

8190
/*
8291
* Clear any allocation the strb may have done and reset all of its

0 commit comments

Comments
 (0)