No matching definitions.

dom/ownstr

src/dom/ownstr.tur

owned String surface shared by tur-xml and tur-html.

Since: 0.1.0

defopaque

String

(String)

an owned, refcounted, immutable string (ABI: ptr<void>).

defn

from-cstr

(from-cstr [s : cstr] :)

copy a borrowed cstr into a new owned String.

sany NUL-terminated cstr (borrowed; not freed)

String -- a fresh String with refcount 1; release it when done.

(let [s (from-cstr "item")]
    (println (to-cstr s))   ; prints item
    (release s))

Since: 0.1.0

defn

adopt-cstr

(adopt-cstr [s : cstr] :)

take ownership of a freshly heap-allocated cstr as a String.

sa malloc'd NUL-terminated cstr; consumed (freed)

String -- a new owned String holding a copy of s's bytes.

(adopt-cstr (some-fn-returning-malloc-cstr))

Since: 0.1.0

defn

to-cstr

(to-cstr [s : String] :)

borrow the String's NUL-terminated bytes (O(1), no copy).

sthe String to borrow from

cstr -- a borrowed view of the same bytes.

(println (to-cstr s))

Since: 0.1.0

defn

retain

(retain [s : String] :)

take an extra reference to a String and return it.

sthe String to keep

String -- the same String, now owned once more by the caller.

(StartElement name _) (do (set! last (retain name)) (Continue))

Since: 0.1.0

defn

release

(release [s : String] :)

drop one reference; the payload is freed at zero.

sthe String whose owning reference is being dropped
(release (node-text n))

Since: 0.1.0

defn

str-len

(str-len [s : String] :)

byte length of the String (not counting the NUL).

sthe String to measure

int -- the byte length.

(str-len (from-cstr "abc"))   ; => 3

Since: 0.1.0

Internal definitions
__from-cstr-raw-- internal: copy a cstr into a fresh String, as a carrier.
__adopt-cstr-raw-- internal: adopt a heap cstr, as a carrier.
__retain-raw-- internal: bump the refcount.
string-- does the String hold exactly the bytes of `c`?