Browse Source

Fix dynstring-strlen on unitialized strings

windows-imgui
Macoy Madson 9 months ago
parent
commit
4dba3384df
  1. 8
      src/DynamicArray.cake

8
src/DynamicArray.cake

@ -135,7 +135,10 @@
;; dynarray-length includes the null terminator. This function removes it
(defun dynstring-strlen (str dynstring &return size_t)
(return (- (dynarray-length str) 1)))
(var length size_t (dynarray-length str))
(return (? (> length 0)
(- length 1)
0)))
;; A very quick way to get a heap-allocated formatted string (quick for the programmer)
(defmacro dynstring-create-f (var-name symbol format-string string
@ -210,6 +213,9 @@
(dynstring-create-f my-quick-string "The answer is %d" 42)
(print-dynstring-details my-quick-string)
(var my-uninitialized-string dynstring null)
(dynstring-concat (addr my-uninitialized-string) "/")
(dynarray-free my-string)
(dynarray-free my-quick-string)
(return 0))))

Loading…
Cancel
Save