ulib uprintf to pipe not termdev, ulib Add stringbuffer and linearlist, tb Capture subshell output
This commit is contained in:
30
ulib/linearlist.h
Normal file
30
ulib/linearlist.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef ULIB_LINEARLIST_H_
|
||||
#define ULIB_LINEARLIST_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <umalloc/umalloc.h>
|
||||
|
||||
#define LINLIST_APPEND(lst, d) \
|
||||
do { \
|
||||
if ((lst)->data == NULL) { \
|
||||
(lst)->capacity = 1; \
|
||||
(lst)->data = umalloc(sizeof(*(lst)->data) * (lst)->capacity); \
|
||||
} else { \
|
||||
if ((lst)->count == (lst)->capacity) { \
|
||||
(lst)->capacity *= 2; \
|
||||
(lst)->data = urealloc((lst)->data, sizeof(*(lst)->data) * (lst)->capacity); \
|
||||
} \
|
||||
} \
|
||||
(lst)->data[(lst)->count++] = (d); \
|
||||
} while(0)
|
||||
|
||||
#define LINLIST_FREE(lst) \
|
||||
do { \
|
||||
if ((lst)->data != NULL) { \
|
||||
ufree((lst)->data); \
|
||||
(lst)->data = NULL; \
|
||||
} \
|
||||
(lst)->count = 0; \
|
||||
} while(0)
|
||||
|
||||
#endif // ULIB_LINEARLIST_H_
|
Reference in New Issue
Block a user