planckforth/lib/string.fs
2021-12-04 21:25:34 +09:00

23 lines
476 B
Forth

\ planckforth -
\ Copyright (C) 2021 nineties
( === String === )
private{
\ Heap-allocated string object
\ p: null terminated string
: make-string ( p -- str )
dup strlen 1 + allocate throw tuck strcpy
; export
: release-string ( str -- ) free ; export
}private
T{ s" AAAAA" make-string constant A -> }T
T{ s" BBBBBBB" make-string constant B -> }T
T{ A s" AAAAA" streq -> true }T
T{ B s" BBBBBBB" streq -> true }T
T{ A release-string -> }T
T{ B release-string -> }T