backup for spsc

This commit is contained in:
Heng Li
2024-10-10 22:43:50 -04:00
parent 0cc3cdca27
commit e4e1f7843b
6 changed files with 143 additions and 2 deletions
+8
View File
@@ -31,6 +31,14 @@ void km_stat_print(const void *km);
#define Kcalloc(km, type, cnt) ((type*)kcalloc((km), (cnt), sizeof(type)))
#define Krealloc(km, type, ptr, cnt) ((type*)krealloc((km), (ptr), (cnt) * sizeof(type)))
#define Kgrow(km, type, ptr, __i, __m) do { \
if ((__i) >= (__m)) { \
(__m) = (__i) + 1; \
(__m) += ((__m)>>1) + 16; \
(ptr) = Krealloc(km, type, ptr, (__m)); \
} \
} while (0)
#define Kexpand(km, type, a, m) do { \
(m) = (m) >= 4? (m) + ((m)>>1) : 16; \
(a) = Krealloc(km, type, (a), (m)); \