@@ -5,19 +5,19 @@
## types
### struct kstr
`struct kstr` is a structure for holding pascal strings (length-prefixed strings). it is the basic libk string type. **note:** if `ptr.ref` ≠ NULL and `sz` = 0, the string's length is unknown and should be calculated by any function that operates on a kstr, storing the result in the object if possible.
- * `size_t sz` - length of string, excluding any null terminator
+ * `sz size` - length of string, excluding any null terminator
* `kmptr ptr` - pointer to string in memory
### struct ksraw
`struct ksraw` is like `kstr` except it uses raw `char` pointers instead of a `kmptr`.
- * `size_t sz` - length of string, excluding any null terminator
+ * `sz size` - length of string, excluding any null terminator
* `char* ptr` - pointer to string in memory
### struct ksbuf
`struct ksbuf` is a structure used to hold buffers.
- * `size_t sz` - maximum size of buffer, including any null terminator
+ * `sz size` - maximum size of buffer, including any null terminator
* `char* buf` - region of memory to store buffer in
* `ksalloc strat` - allocation strategy
* `kmkind rule` - kind of allocator to use. only needs to be set if `where` is NULL. see [kmem](../kmem/kmem.md).
* `kmcell* where` - where to allocate the object, in case of pool or tree allocation.
@@ -26,10 +26,10 @@
`struct kschain` is a structure used for string accumulators that works by aggregating pointers to strings, instead of copying the strings themselves.
* `kschain_kind kind` - kind of chain
* `kmkind rule` - kind of allocation to use if `kind` ≠ `kschain_kind_linked`
* `pstr* ptrs` - pointer to pointer list
- * `size_t ptrc` - number of pointers
- * `size_t sz` - total amount of space in `ptrs`
+ * `sz ptrc` - number of pointers
+ * `sz size` - total amount of space in `ptrs`
#### enum kschain_kind
* `kschain_kind_block` - occupies a single block of memory
* `kschain_kind_linked` - uses a linked list, allocated and deallocated as necessary
@@ -64,12 +64,12 @@
Kstr(""),
ksref(text),
Kstr("")
};
- char* html = kscomp([Kmsz(chain)](../kmem/kmem.md), chain, &buf);
+ char* html = kscomp(Kmsz(chain), chain, &buf);
kscomp will only calculate the length of individual strings if they are not already known. when it needs to calculate the length of a string, it will store that length in the original array so repeated calls can be made without needing to repeatedly calculate the lengths. this is not always desirable, so the variant `kscompc` exists, which is exactly the same as `kscomp` in every respect except that `chain` is not altered in any way.
### macros
if `KFclean` is not set when is included, the following macros are defined.
* `Kstr(string)` - the compile-time equivalent to `kstr()`. `Kstr` takes a literal string and inserts the text `{ sizeof (string), string }` into the document, suitable for initializing a kstr.