diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-16 09:37:02 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-16 09:37:02 -0800 |
commit | 70ced4b3ae240e4f33d26196ec1df8b6e8d0ae9b (patch) | |
tree | 626e08a45d2757cb8cc34bc1f6cf967ee15e1d30 | |
parent | a6c72d88711c2fc537c6f8ca205a5fd2675d8952 (diff) | |
download | txr-70ced4b3ae240e4f33d26196ec1df8b6e8d0ae9b.tar.gz txr-70ced4b3ae240e4f33d26196ec1df8b6e8d0ae9b.tar.bz2 txr-70ced4b3ae240e4f33d26196ec1df8b6e8d0ae9b.zip |
buf-alloc-size: new function.
* buf.c (buf_alloc_size): New function.
(buf_init): buf-alloc-size intrinsic registered.
* buf.h (buf_alloc_size): Declared.
* txr.1: Documented.
-rw-r--r-- | buf.c | 8 | ||||
-rw-r--r-- | buf.h | 1 | ||||
-rw-r--r-- | txr.1 | 9 |
3 files changed, 18 insertions, 0 deletions
@@ -220,6 +220,13 @@ val length_buf(val buf) return b->len; } +val buf_alloc_size(val buf) +{ + val self = lit("buf-alloc-size"); + struct buf *b = buf_handle(buf, self); + return b->size; +} + mem_t *buf_get(val buf, val self) { struct buf *b = buf_handle(buf, self); @@ -943,6 +950,7 @@ void buf_init(void) reg_fun(intern(lit("buf-trim"), user_package), func_n1(buf_trim)); reg_fun(intern(lit("buf-set-length"), user_package), func_n3o(buf_set_length, 2)); reg_fun(intern(lit("length-buf"), user_package), func_n1(length_buf)); + reg_fun(intern(lit("buf-alloc-size"), user_package), func_n1(buf_alloc_size)); reg_fun(intern(lit("copy-buf"), user_package), func_n1(copy_buf)); #if HAVE_I8 @@ -34,6 +34,7 @@ val copy_buf(val buf); val buf_trim(val buf); val buf_set_length(val obj, val len, val init_val); val length_buf(val buf); +val buf_alloc_size(val buf); mem_t *buf_get(val buf, val self); void buf_fill(val buf, mem_t *src, val self); @@ -57356,6 +57356,15 @@ Note: the generic .code length function is also applicable to buffers. +.coNP Function @ buf-alloc-size +.synb +.mets (buf-alloc-size << buf ) +.syne +.desc +The +.code buf-alloc-size +function retrieves the allocation size of the buffer. + .coNP Function @ buf-trim .synb .mets (buf-trim << buf ) |