Commit 054f542adf1f702ef047fe2a3285a809bd4b98d1

Thomas de Grivel 2023-01-30T10:38:08

wip remove alloca

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
diff --git a/c3s/c3s.c b/c3s/c3s.c
index cae8f18..129b6a3 100644
--- a/c3s/c3s.c
+++ b/c3s/c3s.c
@@ -64,8 +64,10 @@ int main (int argc, char **argv)
   s_module c3;
   s_env env;
   s_facts facts;
+  s8 i[BUF_SIZE];
   s_buf in;
   s_tag input;
+  s8 o[BUF_SIZE];
   s_buf out;
   sw r;
   s_tag result;
@@ -74,9 +76,9 @@ int main (int argc, char **argv)
   c3_init(&c3, &facts);
   if (argc < 1)
     return usage(argv[0]);
-  BUF_INIT_ALLOCA(&in, BUFSZ);
+  buf_init(&in, false, sizeof(i), i);
   buf_file_open_r(&in, stdin);
-  BUF_INIT_ALLOCA(&out, BUFSZ);
+  buf_init(&out, false, sizeof(o), o);
   buf_file_open_w(&out, stdout);
   env_init(&env);
   while ((r = buf_xfer_spaces(&out, &in)) >= 0) {
diff --git a/ic3/ic3.c b/ic3/ic3.c
index ed8815c..b43a2e8 100644
--- a/ic3/ic3.c
+++ b/ic3/ic3.c
@@ -64,8 +64,10 @@ int main (int argc, char **argv)
   s_module c3;
   s_env env;
   s_facts facts;
+  s8 i[BUF_SIZE];
   s_buf in;
   s_tag input;
+  s8 o[BUF_SIZE];
   s_buf out;
   sw r;
   s_tag result;
@@ -74,10 +76,10 @@ int main (int argc, char **argv)
   c3_init(&c3, &facts);
   if (argc < 1)
     return usage(argv[0]);
-  BUF_INIT_ALLOCA(&in, BUFSZ);
+  buf_init(&in, false, sizeof(i), i);
   buf_linenoise_open_r(&in, "ic3> ");
   in.line = 0;
-  BUF_INIT_ALLOCA(&out, BUFSZ);
+  buf_init(&out, false, sizeof(o), o);
   buf_file_open_w(&out, stdout);
   env_init(&env);
   while ((r = buf_xfer_spaces(&out, &in)) >= 0) {
diff --git a/libc3/buf.h b/libc3/buf.h
index 314dbf8..ef0a5f7 100644
--- a/libc3/buf.h
+++ b/libc3/buf.h
@@ -26,17 +26,6 @@
 #include <stdlib.h>
 #include "types.h"
 
-#define BUF_INIT_ALLOCA(buf, size)              \
-  do {                                          \
-    s8 *p;                                      \
-    assert(buf);                                \
-    assert(size);                               \
-    p = alloca(size);                           \
-    if (!p)                                     \
-      err(1, "out of memory");                  \
-    buf_init((buf), false, (size), p);          \
-  } while (0)
-
 #define BUF_SIZE 1024
 
 extern const sw buf_u8_to_hex_size;
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index cb5031b..69a275d 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -124,8 +124,9 @@ sw buf_inspect_f32 (s_buf *buf, f32 x)
 
 sw buf_inspect_f32_size (f32 x)
 {
+  s8 b[16];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   return buf_inspect_f32(&buf, x);
 }
 
@@ -136,8 +137,9 @@ sw buf_inspect_f64 (s_buf *buf, f64 x)
 
 sw buf_inspect_f64_size (f64 x)
 {
+  s8 b[16];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   return buf_inspect_f64(&buf, x);
 }
 
@@ -587,6 +589,7 @@ sw buf_inspect_str_byte (s_buf *buf, u8 x)
 
 sw buf_inspect_str_character (s_buf *buf, character x)
 {
+  s8 b[4];
   s_buf char_buf;
   int i;
   int j;
@@ -608,7 +611,7 @@ sw buf_inspect_str_character (s_buf *buf, character x)
   case '\'': if ((r = buf_write_u8(buf, '\'')) < 0) return r; break;
   case '\\': if ((r = buf_write_u8(buf, '\\')) < 0) return r; break;
   default:
-    BUF_INIT_ALLOCA(&char_buf, 4);
+    buf_init(&char_buf, false, sizeof(b), b);
     if ((i = buf_write_character_utf8(&char_buf, x)) < 0)
       return i;
     j = 0;
@@ -915,8 +918,9 @@ sw buf_inspect_u8 (s_buf *buf, u8 x)
   sw i;
   sw r;
   sw size = 0;
+  s8 t[3];
   s_buf tmp;
-  BUF_INIT_ALLOCA(&tmp, 3);
+  buf_init(&tmp, false, sizeof(t), t);
   if (x == 0)
     return buf_write_u8(buf, '0');
   while (x > 0) {
@@ -952,8 +956,9 @@ sw buf_inspect_u16 (s_buf *buf, u16 x)
   sw i;
   sw r;
   sw size = 0;
+  s8 t[5];
   s_buf tmp;
-  BUF_INIT_ALLOCA(&tmp, 5);
+  buf_init(&tmp, false, sizeof(t), t);
   if (x == 0)
     return buf_write_u8(buf, '0');
   while (x > 0) {
@@ -989,8 +994,9 @@ sw buf_inspect_u32 (s_buf *buf, u32 x)
   sw i;
   sw r;
   sw size = 0;
+  s8 t[10];
   s_buf tmp;
-  BUF_INIT_ALLOCA(&tmp, 10);
+  buf_init(&tmp, false, sizeof(t), t);
   if (x == 0)
     return buf_write_u8(buf, '0');
   while (x > 0) {
@@ -1026,8 +1032,9 @@ sw buf_inspect_u64 (s_buf *buf, u64 x)
   sw i;
   sw r;
   sw size = 0;
+  s8 t[20];
   s_buf tmp;
-  BUF_INIT_ALLOCA(&tmp, 20);
+  buf_init(&tmp, false, sizeof(t), t);
   if (x == 0)
     return buf_write_u8(buf, '0');
   while (x > 0) {
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 107f925..0c071bf 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -551,6 +551,7 @@ sw buf_parse_ident (s_buf *buf, s_ident *dest)
   sw result = 0;
   s_buf_save save;
   s_str str;
+  s8 t[IDENT_MAX];
   s_buf tmp;
   assert(buf);
   assert(dest);
@@ -581,7 +582,7 @@ sw buf_parse_ident (s_buf *buf, s_ident *dest)
     goto restore;
   if (r > 0 && ! ident_first_character_is_reserved(c)) {
     csize = r;
-    BUF_INIT_ALLOCA(&tmp, IDENT_MAX);
+    buf_init(&tmp, false, sizeof(t), t);
     if ((r = buf_xfer(&tmp, buf, csize)) < 0)
       goto restore;
     result += csize;
@@ -1175,13 +1176,14 @@ sw buf_parse_str_u8 (s_buf *buf, u8 *dest)
 
 sw buf_parse_sym (s_buf *buf, const s_sym **dest)
 {
-  s_buf tmp;
   character c;
   sw csize;
   sw r;
   sw result = 0;
   s_buf_save save;
   s_str str;
+  s8 t[SYM_MAX];
+  s_buf tmp;
   assert(buf);
   assert(dest);
   buf_save_init(buf, &save);
@@ -1203,7 +1205,7 @@ sw buf_parse_sym (s_buf *buf, const s_sym **dest)
     goto clean;
   if (c == ':' || character_is_uppercase(c)) {
     csize = r;
-    BUF_INIT_ALLOCA(&tmp, SYM_MAX);
+    buf_init(&tmp, false, sizeof(t), t);
     if (c == ':') {
       if ((r = buf_ignore(buf, csize)) < 0)
         goto clean;
diff --git a/libc3/facts.c b/libc3/facts.c
index fc34cf5..fd7e1fa 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -143,12 +143,13 @@ sw facts_dump (const s_facts *facts, s_buf *buf)
 
 sw facts_dump_file (const s_facts *facts, const s8 *path)
 {
+  s8 b[BUF_SIZE];
   s_buf buf;
   FILE *fp;
   sw r;
   assert(facts);
   assert(path);
-  BUF_INIT_ALLOCA(&buf, 1024);
+  buf_init(&buf, false, sizeof(b), b);
   if (! (fp = fopen(path, "wb"))) {
     warn("fopen: %s", path);
     return -1;
@@ -274,12 +275,13 @@ sw facts_load (s_facts *facts, s_buf *buf)
 
 sw facts_load_file (s_facts *facts, const s8 *path)
 {
+  s8 b[BUF_SIZE];
   s_buf buf;
   FILE *fp;
   sw result;
   assert(facts);
   assert(path);
-  BUF_INIT_ALLOCA(&buf, 1024);
+  buf_init(&buf, false, sizeof(b), b);
   fp = fopen(path, "r");
   buf_file_open_r(&buf, fp);
   result = facts_load(facts, &buf);
@@ -357,10 +359,11 @@ sw facts_open_buf (s_facts *facts, s_buf *buf)
 sw facts_open_file (s_facts *facts, const s8 *path)
 {
   FILE *fp;
+  s8 i[BUF_SIZE];
   s_buf in;
   sw r;
   sw result = 0;
-  BUF_INIT_ALLOCA(&in, BUF_SIZE);
+  buf_init(&in, false, sizeof(i), i);
   if (! (fp = fopen(path, "rb"))) {
     if (errno == ENOENT)
       return facts_open_file_create(facts, path);
@@ -482,6 +485,7 @@ e_bool facts_remove_fact (s_facts *facts, const s_fact *fact)
 
 sw facts_save_file (s_facts *facts, const s8 *path)
 {
+  s8 b[BUF_SIZE];
   s_buf buf;
   FILE *fp;
   sw r;
@@ -489,7 +493,7 @@ sw facts_save_file (s_facts *facts, const s8 *path)
   assert(facts);
   assert(path);
   assert(! facts->log);
-  BUF_INIT_ALLOCA(&buf, BUF_SIZE);
+  buf_init(&buf, false, sizeof(b), b);
   if (! (fp = fopen(path, "wb"))) {
     warn("fopen: %s", path);
     return -1;
diff --git a/libc3/skiplist.h.in b/libc3/skiplist.h.in
index 6d9d85b..ee97918 100644
--- a/libc3/skiplist.h.in
+++ b/libc3/skiplist.h.in
@@ -29,10 +29,6 @@
 #define SKIPLIST_SIZE___NAME$(max_height) \
   (sizeof(s_skiplist___NAME$) + (max_height) * sizeof(t_skiplist_height))
 
-#define SKIPLIST_INIT_ALLOCA___NAME$(max_height, spacing) \
-  (skiplist_init___NAME$(alloca(SKIPLIST_SIZE___NAME$(max_height)), \
-                         (max_height), (spacing)))
-
 void
 skiplist_clean___NAME$ (s_skiplist___NAME$ *skiplist);
 
diff --git a/libc3/skiplist__fact.h b/libc3/skiplist__fact.h
index b275df4..20f97e6 100644
--- a/libc3/skiplist__fact.h
+++ b/libc3/skiplist__fact.h
@@ -29,10 +29,6 @@
 #define SKIPLIST_SIZE__fact(max_height) \
   (sizeof(s_skiplist__fact) + (max_height) * sizeof(t_skiplist_height))
 
-#define SKIPLIST_INIT_ALLOCA__fact(max_height, spacing) \
-  (skiplist_init__fact(alloca(SKIPLIST_SIZE__fact(max_height)), \
-                         (max_height), (spacing)))
-
 void
 skiplist_clean__fact (s_skiplist__fact *skiplist);
 
diff --git a/test/buf_file_test.c b/test/buf_file_test.c
index 29ba740..a1e3084 100644
--- a/test/buf_file_test.c
+++ b/test/buf_file_test.c
@@ -30,11 +30,12 @@ void buf_file_test ()
 
 void buf_file_test_open_r_close ()
 {
+  s8 b[16];
   s_buf buf;
   FILE *fp;
   fp = fopen("/dev/null", "r");
   assert(fp);
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_file_open_r(&buf, fp), &buf);
   buf_file_close(&buf);
   test_ok();
@@ -44,13 +45,14 @@ void buf_file_test_open_r_close ()
 void buf_file_test_open_r_refill ()
 {
   u8 b = 0x80;
+  s8 bu[16];
   s_buf buf;
   FILE *fp;
   sw i = 64;
   test_context("buf_file_open_r_refill(/dev/zero)");
   fp = fopen("/dev/zero", "r");
   assert(fp);
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(bu), bu);
   buf_file_open_r(&buf, fp);
   while (i--) {
     TEST_EQ(buf_read_u8(&buf, &b), 1);
diff --git a/test/buf_inspect_test.c b/test/buf_inspect_test.c
index 392c5ab..7274987 100644
--- a/test/buf_inspect_test.c
+++ b/test/buf_inspect_test.c
@@ -18,9 +18,10 @@
 
 #define BUF_INSPECT_TEST_BOOL(test, expected)                          \
   do {                                                                 \
+    s8 b[16];                                                          \
     s_buf buf;                                                         \
     test_context("buf_inspect_bool(" # test ") -> " # expected);       \
-    BUF_INIT_ALLOCA(&buf, 16);                                         \
+    buf_init(&buf, false, sizeof(b), b);                               \
     TEST_EQ(buf_inspect_bool(&buf, (test)), strlen(expected));         \
     TEST_STRNCMP(buf.ptr.p, (expected), buf.wpos);                     \
     test_context(NULL);                                                \
@@ -39,9 +40,10 @@
 
 #define BUF_INSPECT_TEST_F32(test, expected)                           \
   do {                                                                 \
+    s8 b[32];                                                          \
     s_buf buf;                                                         \
     test_context("buf_inspect_f32(" # test ") -> " # expected);        \
-    BUF_INIT_ALLOCA(&buf, 32);                                         \
+    buf_init(&buf, false, sizeof(b), b);                               \
     TEST_EQ(buf_inspect_f32_size(test), strlen(expected));             \
     TEST_EQ(buf_inspect_f32(&buf, test), strlen(expected));            \
     TEST_STRNCMP(buf.ptr.ps8, (expected), buf.wpos);                   \
@@ -50,9 +52,10 @@
 
 #define BUF_INSPECT_TEST_F64(test, expected)                           \
   do {                                                                 \
+    s8 b[64];                                                          \
     s_buf buf;                                                         \
     test_context("buf_inspect_f64(" # test ") -> " # expected);        \
-    BUF_INIT_ALLOCA(&buf, 64);                                         \
+    buf_init(&buf, false, sizeof(b), b);                               \
     TEST_EQ(buf_inspect_f64_size(test), strlen(expected));             \
     TEST_EQ(buf_inspect_f64(&buf, test), strlen(expected));            \
     TEST_STRNCMP(buf.ptr.ps8, (expected), buf.wpos);                   \
diff --git a/test/buf_test.c b/test/buf_test.c
index bbc4cce..2b0050c 100644
--- a/test/buf_test.c
+++ b/test/buf_test.c
@@ -214,8 +214,9 @@ void buf_test ()
 
 void buf_test_f ()
 {
+  s8 b[32];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 32);
+  buf_init(&buf, false, sizeof(b), b);          \
   BUF_TEST_F(buf_f(&buf, "09AZaz"), "09AZaz");
   BUF_TEST_F(buf_f(&buf, "%d", 0), "0");
   BUF_TEST_F(buf_f(&buf, "%d", 42), "42");
@@ -253,23 +254,23 @@ void buf_test_init_clean ()
   char a[4] = "test";
   size_t len;
   char *m;
-  s_buf bufa;
+  s_buf buf;
   len = 4;
-  buf_init(&bufa, false, len, a);
-  TEST_EQ(bufa.size, len);
-  TEST_EQ(strncmp(bufa.ptr.p, "test", len), 0);
-  TEST_EQ(bufa.rpos, 0);
-  TEST_EQ(bufa.wpos, 0);
-  BUF_TEST_CLEAN(bufa);
+  buf_init(&buf, false, len, a);
+  TEST_EQ(buf.size, len);
+  TEST_EQ(strncmp(buf.ptr.p, "test", len), 0);
+  TEST_EQ(buf.rpos, 0);
+  TEST_EQ(buf.wpos, 0);
+  BUF_TEST_CLEAN(buf);
   len = 4;
   m = malloc(len);
   memcpy(m, "test", len);
-  buf_init(&bufa, true, len, m);
-  TEST_EQ(bufa.size, len);
-  TEST_EQ(strncmp(bufa.ptr.p, "test", len), 0);
-  TEST_EQ(bufa.rpos, 0);
-  TEST_EQ(bufa.wpos, 0);
-  BUF_TEST_CLEAN(bufa);
+  buf_init(&buf, true, len, m);
+  TEST_EQ(buf.size, len);
+  TEST_EQ(strncmp(buf.ptr.p, "test", len), 0);
+  TEST_EQ(buf.rpos, 0);
+  TEST_EQ(buf.wpos, 0);
+  BUF_TEST_CLEAN(buf);
 }
 
 void buf_test_new_delete ()
@@ -359,9 +360,10 @@ void buf_test_peek_s8 ()
 
 void buf_test_peek_s16 ()
 {
+  s8 b[8];
   s_buf buf;
   s16 val;
-  BUF_INIT_ALLOCA(&buf, 8);
+  buf_init(&buf, false, sizeof(b), b);          \
   TEST_EQ(buf_write_s16(&buf, 0), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
@@ -431,9 +433,10 @@ void buf_test_read_character_utf8 ()
 
 void buf_test_read_f32()
 {
+  s8 b[16];
   s_buf buf;
   f32 f;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_f32(&buf, 1.0f), 4);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 4);
@@ -459,9 +462,10 @@ void buf_test_read_f32()
 
 void buf_test_read_f64 ()
 {
+  s8 b[32];
   s_buf buf;
   f64 f;
-  BUF_INIT_ALLOCA(&buf, 32);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_f64(&buf, 1.0), 8);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 8);
@@ -529,9 +533,10 @@ void buf_test_read_s8 ()
 
 void buf_test_read_s16 ()
 {
+  s8 b[8];
   s_buf buf;
   s16 val;
-  BUF_INIT_ALLOCA(&buf, 8);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s16(&buf, 0), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
@@ -552,9 +557,10 @@ void buf_test_read_s16 ()
 
 void buf_test_read_s32()
 {
-  s32 val;
+  s8 b[16];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 16);
+  s32 val;
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s32(&buf, 0x00000000), 4);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 4);
@@ -580,9 +586,10 @@ void buf_test_read_s32()
 
 void buf_test_read_s64()
 {
-  s64 val;
+  s8 b[32];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 32);
+  s64 val;
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s64(&buf, 0x0000000000000000), 8);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 8);
@@ -649,9 +656,10 @@ void buf_test_read_u8 ()
 
 void buf_test_read_u16()
 {
+  s8 b[8];
   s_buf buf;
   u16 val;
-  BUF_INIT_ALLOCA(&buf, 8);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u16(&buf, 0x0000), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
@@ -677,9 +685,10 @@ void buf_test_read_u16()
 
 void buf_test_read_u32()
 {
+  s8 b[16];
   s_buf buf;
   u32 val;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u32(&buf, 0x00000000), 4);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 4);
@@ -705,9 +714,10 @@ void buf_test_read_u32()
 
 void buf_test_read_u64()
 {
+  s8 b[32];
   s_buf buf;
   u64 val;
-  BUF_INIT_ALLOCA(&buf, 32);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u64(&buf, 0x0000000000000000), 8);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 8);
@@ -733,8 +743,9 @@ void buf_test_read_u64()
 
 void buf_test_write_s8 ()
 {
+  s8 b[4];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 4);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s8(&buf, 0x00), 1);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 1);
@@ -755,8 +766,9 @@ void buf_test_write_s8 ()
 
 void buf_test_write_s16 ()
 {
+  s8 b[8];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 8);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s16(&buf, 0x0000), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
@@ -777,8 +789,9 @@ void buf_test_write_s16 ()
 
 void buf_test_write_s32 ()
 {
+  s8 b[16];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s32(&buf, 0x00000000), 4);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 4);
@@ -799,8 +812,9 @@ void buf_test_write_s32 ()
 
 void buf_test_write_s64 ()
 {
+  s8 b[32];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 32);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_s64(&buf, 0x0000000000000000), 8);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 8);
@@ -821,8 +835,9 @@ void buf_test_write_s64 ()
 
 void buf_test_write_u8 ()
 {
+  s8 b[4];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 4);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u8(&buf, 0x00), 1);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 1);
@@ -843,8 +858,9 @@ void buf_test_write_u8 ()
 
 void buf_test_write_u16 ()
 {
+  s8 b[8];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 8);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u16(&buf, 0x0000), 2);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 2);
@@ -865,8 +881,9 @@ void buf_test_write_u16 ()
 
 void buf_test_write_u32 ()
 {
+  s8 b[16];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 16);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u32(&buf, 0x00000000), 4);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 4);
@@ -887,8 +904,9 @@ void buf_test_write_u32 ()
 
 void buf_test_write_u64 ()
 {
+  s8 b[32];
   s_buf buf;
-  BUF_INIT_ALLOCA(&buf, 32);
+  buf_init(&buf, false, sizeof(b), b);
   TEST_EQ(buf_write_u64(&buf, 0x0000000000000000), 8);
   TEST_EQ(buf.rpos, 0);
   TEST_EQ(buf.wpos, 8);
@@ -913,14 +931,16 @@ void buf_test_write_str ()
 
 void buf_test_xfer ()
 {
-  const char a[] = "0123456789ABCDEF";
+  const s8 a[16] = "0123456789ABCDEF";
+  s8 d[16];
   s_buf dest;
+  s8 s[16];
   s_buf src;
   s_str str;
   str_init_1(&str, NULL, a);
-  BUF_INIT_ALLOCA(&src, sizeof(a));
+  buf_init(&src, false, sizeof(s), s);
   buf_write_str(&src, &str);
-  BUF_INIT_ALLOCA(&dest, sizeof(a));
+  buf_init(&dest, false, sizeof(d), d);
   TEST_EQ(buf_xfer(&dest, &src, 0), 0);
   TEST_EQ(buf_xfer(&dest, &src, 1), 1);
   TEST_EQ(buf_xfer(&dest, &src, 2), 2);
diff --git a/test/skiplist__fact_test.c b/test/skiplist__fact_test.c
index b2829d0..81a4666 100644
--- a/test/skiplist__fact_test.c
+++ b/test/skiplist__fact_test.c
@@ -23,22 +23,22 @@
   do {                                                                 \
     test_context("skiplist_insert__fact(" # test ") -> "               \
                  # expected_length);                                   \
-    TEST_ASSERT(skiplist_insert__fact(skiplist, (test)));              \
-    TEST_EQ(skiplist->length, (expected_length));                      \
+    TEST_ASSERT(skiplist_insert__fact(&skiplist, (test)));             \
+    TEST_EQ(skiplist.length, (expected_length));                       \
     test_context(NULL);                                                \
   } while (0)
 
 #define SKIPLIST__FACT_TEST_INIT_CLEAN(max_height_, spacing)           \
   do {                                                                 \
-    s_skiplist__fact *skiplist;                                        \
-    TEST_ASSERT((skiplist = SKIPLIST_INIT_ALLOCA__fact(max_height_,    \
-                                                       spacing)));     \
-    TEST_ASSERT(skiplist->head);                                       \
-    TEST_ASSERT(skiplist->compare);                                    \
-    TEST_EQ(skiplist->length, 0);                                      \
-    TEST_EQ(skiplist->max_height, max_height_);                        \
-    TEST_EQ(skiplist->head->height, max_height_);                      \
-    skiplist_clean__fact(skiplist);                                    \
+    s_skiplist__fact skiplist;                                         \
+    TEST_ASSERT(skiplist_init__fact(&skiplist, max_height_,            \
+                                    spacing));                         \
+    TEST_ASSERT(skiplist.head);                                        \
+    TEST_ASSERT(skiplist.compare);                                     \
+    TEST_EQ(skiplist.length, 0);                                       \
+    TEST_EQ(skiplist.max_height, max_height_);                         \
+    TEST_EQ(skiplist.head->height, max_height_);                       \
+    skiplist_clean__fact(&skiplist);                                   \
     test_ok();                                                         \
   } while (0)
 
@@ -60,8 +60,8 @@
   do {                                                                 \
     test_context("skiplist_remove__fact(" # test ") -> "               \
                  # expected_length);                                   \
-    skiplist_remove__fact(skiplist, (test));                           \
-    TEST_EQ(skiplist->length, (expected_length));                      \
+    skiplist_remove__fact(&skiplist, (test));                          \
+    TEST_EQ(skiplist.length, (expected_length));                       \
     test_context(NULL);                                                \
   } while (0)
 
@@ -114,25 +114,25 @@ void skiplist__fact_test_find ()
     NULL
   };
   const double *s;
-  s_skiplist__fact *skiplist;
+  s_skiplist__fact skiplist;
   const double spacing[] = {2.0, 2.4, 3.0, 0.0};
   for (h = height; *h; h++) {
     for (s = spacing; *s != 0.0; s++) {
-      skiplist = SKIPLIST_INIT_ALLOCA__fact(*h, *s);
+      skiplist_init__fact(&skiplist, *h, *s);
       i = 0;
       while (p[i]) {
         fact_test_init_1(fact + i, p[i]);
-        skiplist_insert__fact(skiplist, fact + i);
-        TEST_ASSERT(skiplist_find__fact(skiplist, fact + i));
+        skiplist_insert__fact(&skiplist, fact + i);
+        TEST_ASSERT(skiplist_find__fact(&skiplist, fact + i));
         i++;
       }
-      i = skiplist->length;
+      i = skiplist.length;
       while (i--) {
-        skiplist_remove__fact(skiplist, fact + i);
-        TEST_ASSERT(! skiplist_find__fact(skiplist, fact + i));
+        skiplist_remove__fact(&skiplist, fact + i);
+        TEST_ASSERT(! skiplist_find__fact(&skiplist, fact + i));
         fact_test_clean_1(fact + i);
       }
-      skiplist_clean__fact(skiplist);
+      skiplist_clean__fact(&skiplist);
     }
   }
 }
@@ -171,7 +171,7 @@ void skiplist__fact_test_insert ()
     NULL
   };
   s_fact fact[24];
-  s_skiplist__fact *skiplist;
+  s_skiplist__fact skiplist;
   i = 0;
   while (p[i]) {
     fact_test_init_1(fact + i, p[i]);
@@ -179,13 +179,13 @@ void skiplist__fact_test_insert ()
   }
   for (h = height; *h; h++) {
     for (s = spacing; *s != 0.0; s++) {
-      skiplist = SKIPLIST_INIT_ALLOCA__fact(*h, *s);
+      skiplist_init__fact(&skiplist, *h, *s);
       i = 0;
       while (p[i]) {
         SKIPLIST__FACT_TEST_INSERT(fact + i, i + 1);
         i++;
       }
-      skiplist_clean__fact(skiplist);
+      skiplist_clean__fact(&skiplist);
     }
   }
   i = 0;
@@ -254,23 +254,23 @@ void skiplist__fact_test_remove ()
     NULL
   };
   const double *s;
-  s_skiplist__fact *skiplist;
+  s_skiplist__fact skiplist;
   const double spacing[] = {2.0, 2.4, 3.0, 0.0};
   for (h = height; *h; h++) {
     for (s = spacing; *s != 0.0; s++) {
-      skiplist = SKIPLIST_INIT_ALLOCA__fact(*h, *s);
+      skiplist_init__fact(&skiplist, *h, *s);
       i = 0;
       while (p[i]) {
         fact_test_init_1(fact + i, p[i]);
-        skiplist_insert__fact(skiplist, fact + i);
+        skiplist_insert__fact(&skiplist, fact + i);
         i++;
       }
-      i = skiplist->length;
+      i = skiplist.length;
       while (i--) {
         SKIPLIST__FACT_TEST_REMOVE(fact + i, i);
         fact_test_clean_1(fact + i);
       }
-      skiplist_clean__fact(skiplist);
+      skiplist_clean__fact(&skiplist);
     }
   }
 }