~lsof/cff

88066fc3b0638281024293d8d8e6a25896090e71 — lemon 6 months ago 173ed45
use arena for interning strings
1 files changed, 8 insertions(+), 2 deletions(-)

M src/util.cff
M src/util.cff => src/util.cff +8 -2
@@ 1,8 1,8 @@
import "util.hff";
import "cffc.hff";
import "set.hff";
import "mem.hff";
import "common.hff";
import "mem.hff";

extern fn xmalloc(n usize) *void {
   let p = malloc(n);


@@ 80,7 80,13 @@ extern fn internstr(s *const u8) *const u8 {
      fn eq(a *const u8, b *const u8) bool {
         return a != #null and b != #null and streq(a, b);
      }
      fn dup(s *const u8) *const u8 { return xstrdup(s); }
      fn dup(s *const u8) *const u8 {
         static arena Arena = {};
         let n = strlen(s) + 1;
         let p = Arena:allocf(&arena, n, 1);
         memcpy(p, s, n);
         return p;
      } 
   }> = {};
   return *set->intern(s);
}