fix online docs examples v4.0

Wed, 31 Dec 2025 16:18:48 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 31 Dec 2025 16:18:48 +0100
changeset 1696
976e629ce990
parent 1695
d21cec66facc
child 1697
ca825e816a50

fix online docs examples

docs/Writerside/topics/buffer.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/mempool.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/streams.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/string.h.md file | annotate | diff | comparison | revisions
--- a/docs/Writerside/topics/buffer.h.md	Wed Dec 31 16:05:38 2025 +0100
+++ b/docs/Writerside/topics/buffer.h.md	Wed Dec 31 16:18:48 2025 +0100
@@ -33,8 +33,8 @@
 	// initialize buffer and use stack memory for small requests
 	char stackmem[128];
 	CxBuffer buf;
-	cxBufferInit(cxDefaultAllocator,
-		&buf, stackmem, sizeof(stackmem),
+	cxBufferInit(&buf, cxDefaultAllocator,
+		stackmem, sizeof(stackmem),
 		CX_BUFFER_COPY_ON_EXTEND // move to heap when request is larger
 	);
 	
--- a/docs/Writerside/topics/mempool.h.md	Wed Dec 31 16:05:38 2025 +0100
+++ b/docs/Writerside/topics/mempool.h.md	Wed Dec 31 16:18:48 2025 +0100
@@ -164,15 +164,14 @@
     cxMempoolRegister(pool, f, (cx_destructor_func) fclose);
 
     // create a buffer using the memory pool for destruction
-    CxBuffer *content = cxBufferCreate(
-            NULL, 256, pool->allocator, CX_BUFFER_AUTO_EXTEND
+    CxBuffer *content = cxBufferCreate(pool->allocator,
+            NULL, 256, CX_BUFFER_AUTO_EXTEND
     );
 
     // read the file into the buffer and turn it into a string
     cx_stream_copy(
         f, content, (cx_read_func) fread, cxBufferWriteFunc
     );
-    fclose(f);
     cxstring contentstr = cx_bstr(content);
 
     // split the string into lines
@@ -185,7 +184,7 @@
     // skip the header and parse the remaining data into a linked list
     // the nodes of the list shall also be allocated by the pool
     CxList* datalist = cxLinkedListCreate(
-        pool->allocator, NULL, sizeof(CSVData)
+        pool->allocator, sizeof(CSVData)
     );
     for (size_t i = 1 ; i < lc ; i++) {
         if (lines[i].length == 0) continue;
--- a/docs/Writerside/topics/streams.h.md	Wed Dec 31 16:05:38 2025 +0100
+++ b/docs/Writerside/topics/streams.h.md	Wed Dec 31 16:18:48 2025 +0100
@@ -56,6 +56,12 @@
 
 The following example shows how to read the contents of a file into a buffer:
 ```c
+#include <cx/buffer.h>
+#include <cx/utils.h>
+#include <stdio.h>
+
+// ...
+
 FILE *inputfile = fopen(infilename, "r");
 if (inputfile) {
     CxBuffer fbuf;
--- a/docs/Writerside/topics/string.h.md	Wed Dec 31 16:05:38 2025 +0100
+++ b/docs/Writerside/topics/string.h.md	Wed Dec 31 16:18:48 2025 +0100
@@ -145,8 +145,11 @@
 
 Example usage:
 ```C
-cxmutstr str = cx_strcat(CX_NULLSTR, 2,
-                         cx_str("Hello, "), cx_str("World!"));
+cxmutstr str = cx_strcat(
+        CX_NULLSTR, 2,
+        cx_str("Hello, "),
+        cx_str("World!")
+);
 ```
 
 The function `cx_strlen()` sums the length of the specified strings.

mercurial