Browse Source

Fix memory leaks

master
Macoy Madson 6 months ago
parent
commit
08d0bc7eb9
  1. 1
      src/AutoUpdate.cake
  2. 33
      src/Introspection.cake

1
src/AutoUpdate.cake

@ -157,6 +157,7 @@
(var output-directory ([] 1024 char) (array 0))
(sprintf output-directory "v%d" (field update-metadata latest-version))
(unless (make-directory output-directory)
(free verified-payload)
(free-introspect-struct-fields auto-update-metadata--metadata (addr update-metadata) free)
(return false))
(unless (decompress-zip-from-memory-to-files

33
src/Introspection.cake

@ -1734,28 +1734,10 @@
free-my-thing
(ignore))
(defun test--introspection-strings (&return int)
(var a my-struct
(array #"#"Hello!" This is a naughty
naughty string with \\ backslashes and such \\#"#
"Other name" (strdup "Another name") null
42 -0.33f (array 0.f 1.f 2.f) (array 10.f 20.f 30.f)
(array (array "Hi" true) (array "Bye" false))
false 'a'
(array "Yep" true)
888
(array 8 9)
;; This doesn't actually write the value yet, but still tests what I wanted to test
;; (pointer overrides)
null))
(unless (introspect-test-struct my-struct--metadata (addr a) "TestSerialize.cakedata")
(return 1))
(return 0))
(defun test--introspection (&return int)
(var a my-struct
(array "Test struct" "Other name" (strdup "Another name") null
(array #"#"Hello!" This is a naughty
naughty string with \\ backslashes and such \\#"# "Other name" (strdup "Another name") null
42 -0.33f (array 0.f 1.f 2.f) (array 10.f 20.f 30.f)
(array (array "Hi" true) (array "Bye" false))
false 'a'
@ -1827,7 +1809,7 @@
(fprintf stderr "Succeeded\n")))
(scope ;; Copy structs
(var a my-struct
(var a-2 my-struct
(array "Test struct" "Other name" (strdup "Another name") null
42 -0.33f (array 0.f 1.f 2.f) (array 10.f 20.f 30.f)
(array (array "Hi" true) (array "Bye" false))
@ -1839,13 +1821,16 @@
;; (pointer overrides)
null))
(var b my-struct (array 0))
(unless (copy-introspect-struct my-struct--metadata (addr b) (addr a) malloc)
(unless (copy-introspect-struct my-struct--metadata (addr b) (addr a-2) malloc)
(return 1))
(unless (= 0 (compare-introspect-struct-print-result my-struct--metadata
(addr a)
(addr a-2)
(addr b)))
(fprintf stderr "error: copied struct does not equal baseline\n")
(return 1)))
(return 1))
(free-introspect-struct-fields
my-struct--metadata (addr b) free)
(free (field a-2 yet-another-name)))
(scope ;; Test errors
(var read-struct my-struct (array 0))

Loading…
Cancel
Save