boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

34-bv-grow.scm (518B)


      1 ; bytevector-grow! enlarges capacity in place; existing data must survive
      2 ; the alloc + copy. Length stays unchanged.
      3 (define b (make-bytevector 5 0))
      4 (bytevector-u8-set! b 0 11)
      5 (bytevector-u8-set! b 1 13)
      6 (bytevector-u8-set! b 4 17)
      7 
      8 ; Force growth past initial 16-byte capacity.
      9 (bytevector-grow! b 100)
     10 
     11 ; Length still 5; bytes still readable.
     12 (sys-exit (+ (bytevector-length b)
     13              (+ (+ (bytevector-u8-ref b 0) (bytevector-u8-ref b 1))
     14                 (bytevector-u8-ref b 4))))
     15 ; 5 + 11 + 13 + 17 = 46