fix allocator of some printf.h functions not being const - fixes #611

Fri, 11 Apr 2025 16:48:58 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 11 Apr 2025 16:48:58 +0200
changeset 1285
7acbaa74fbd0
parent 1284
b2103354baed
child 1286
5492e8ef05f4

fix allocator of some printf.h functions not being const - fixes #611

CHANGELOG file | annotate | diff | comparison | revisions
docs/Writerside/topics/about.md file | annotate | diff | comparison | revisions
src/cx/printf.h file | annotate | diff | comparison | revisions
src/printf.c file | annotate | diff | comparison | revisions
--- a/CHANGELOG	Fri Apr 11 16:45:20 2025 +0200
+++ b/CHANGELOG	Fri Apr 11 16:48:58 2025 +0200
@@ -4,6 +4,7 @@
  * adds cxMempoolTransfer() and cxMempoolTransferObject()
  * changes grow strategy for the mempory pool to reduce reallocations
  * fixes implementation of cxBufferTerminate()
+ * fixes allocator arguments for some printf.h functions not being const
 
 Version 3.1 - 2025-02-11
 ------------------------
--- a/docs/Writerside/topics/about.md	Fri Apr 11 16:45:20 2025 +0200
+++ b/docs/Writerside/topics/about.md	Fri Apr 11 16:48:58 2025 +0200
@@ -31,6 +31,7 @@
 * adds cxMempoolTransfer() and cxMempoolTransferObject()
 * changes grow strategy for the mempory pool to reduce reallocations
 * fixes implementation of cxBufferTerminate()
+* fixes allocator arguments for some printf.h functions not being const 
 
 ### Version 3.1 - 2025-02-11 {collapsible="true"}
 
--- a/src/cx/printf.h	Fri Apr 11 16:45:20 2025 +0200
+++ b/src/cx/printf.h	Fri Apr 11 16:48:58 2025 +0200
@@ -229,7 +229,7 @@
 cx_attr_cstr_arg(4)
 cx_attr_export
 int cx_sprintf_a(
-        CxAllocator *alloc,
+        const CxAllocator *alloc,
         char **str,
         size_t *len,
         const char *fmt,
@@ -274,7 +274,7 @@
 cx_attr_access_rw(3)
 cx_attr_export
 int cx_vsprintf_a(
-        CxAllocator *alloc,
+        const CxAllocator *alloc,
         char **str,
         size_t *len,
         const char *fmt,
@@ -333,7 +333,7 @@
 cx_attr_access_rw(4)
 cx_attr_export
 int cx_sprintf_sa(
-        CxAllocator *alloc,
+        const CxAllocator *alloc,
         char *buf,
         size_t *len,
         char **str,
@@ -388,7 +388,7 @@
 cx_attr_cstr_arg(5)
 cx_attr_export
 int cx_vsprintf_sa(
-        CxAllocator *alloc,
+        const CxAllocator *alloc,
         char *buf,
         size_t *len,
         char **str,
--- a/src/printf.c	Fri Apr 11 16:45:20 2025 +0200
+++ b/src/printf.c	Fri Apr 11 16:48:58 2025 +0200
@@ -132,7 +132,13 @@
     return s;
 }
 
-int cx_sprintf_a(CxAllocator *alloc, char **str, size_t *len, const char *fmt, ... ) {
+int cx_sprintf_a(
+        const CxAllocator *alloc,
+        char **str,
+        size_t *len,
+        const char *fmt,
+        ...
+) {
     va_list ap;
     va_start(ap, fmt);
     int ret = cx_vsprintf_a(alloc, str, len, fmt, ap);
@@ -140,7 +146,13 @@
     return ret;
 }
 
-int cx_vsprintf_a(CxAllocator *alloc, char **str, size_t *len, const char *fmt, va_list ap) {
+int cx_vsprintf_a(
+        const CxAllocator *alloc,
+        char **str,
+        size_t *len,
+        const char *fmt,
+        va_list ap
+) {
     va_list ap2;
     va_copy(ap2, ap);
     int ret = vsnprintf(*str, *len, fmt, ap);
@@ -162,7 +174,14 @@
     return ret;
 }
 
-int cx_sprintf_sa(CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt, ... ) {
+int cx_sprintf_sa(
+        const CxAllocator *alloc,
+        char *buf,
+        size_t *len,
+        char **str,
+        const char *fmt,
+        ...
+) {
     va_list ap;
     va_start(ap, fmt);
     int ret = cx_vsprintf_sa(alloc, buf, len, str, fmt, ap);
@@ -170,7 +189,14 @@
     return ret;
 }
 
-int cx_vsprintf_sa(CxAllocator *alloc, char *buf, size_t *len, char **str, const char *fmt, va_list ap) {
+int cx_vsprintf_sa(
+        const CxAllocator *alloc,
+        char *buf,
+        size_t *len,
+        char **str,
+        const char *fmt,
+        va_list ap
+) {
     va_list ap2;
     va_copy(ap2, ap);
     int ret = vsnprintf(buf, *len, fmt, ap);

mercurial