diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fdd89c..b31c7db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Run tests run: | set -euo pipefail - carp -x test/strbuf.carp + carp -x --log-memory test/strbuf.carp - name: Install angler run: | diff --git a/README.md b/README.md index 3bd27bc..694ea9d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A growable string buffer for Carp. ## Installation ```clojure -(load "git@github.com:carpentry-org/strbuf@0.2.0") +(load "git@github.com:carpentry-org/strbuf@0.2.1") ``` ## Usage @@ -45,7 +45,7 @@ allocates a new string on every call. ## Testing ``` -carp -x test/strbuf.carp +carp -x --log-memory test/strbuf.carp ```
StringBuf tracks capacity and grows geometrically, giving
amortized O(1) appends.
(load "git@github.com:carpentry-org/strbuf@0.2.0")
+(load "git@github.com:carpentry-org/strbuf@0.2.1")
Usage
(let [sb (StringBuf.create)]
diff --git a/strbuf.carp b/strbuf.carp
index d30fe12..5e81c0d 100644
--- a/strbuf.carp
+++ b/strbuf.carp
@@ -6,7 +6,7 @@ amortized O(1) appends.
## Installation
```
-(load \"git@github.com:carpentry-org/strbuf@0.2.0\")
+(load \"git@github.com:carpentry-org/strbuf@0.2.1\")
```
## Usage
@@ -77,6 +77,7 @@ modifying the buffer.")
(doc delete "frees the buffer.")
(register delete (Fn [StringBuf] ()))
+ (implements delete StringBuf.delete)
(register copy (Fn [&StringBuf] StringBuf))
(implements copy StringBuf.copy))
diff --git a/test/strbuf.carp b/test/strbuf.carp
index 1eeb8df..36f2f75 100644
--- a/test/strbuf.carp
+++ b/test/strbuf.carp
@@ -155,4 +155,12 @@
&(let-do [sb (StringBuf.with-capacity 0)]
(StringBuf.append-str &sb "hello")
(let-do [s (StringBuf.to-string &sb)] (StringBuf.delete sb) s))
- "with-capacity 0 buffer grows and is usable"))
+ "with-capacity 0 buffer grows and is usable")
+
+ (assert-equal test
+ 0l
+ (do
+ (Debug.reset-memory-balance!)
+ (let [sb (StringBuf.create)] ())
+ (Debug.memory-balance))
+ "owned buffers are deleted automatically at scope exit"))