Browse Source

Fix memory leak in Export

* Mess with valgrind command to work even if opening file
explorer (did not work)
* Pre-allocate child entries to have less resizing
* Add option to not open explorer on export (not sure if this should
stay or not)
filter-focus
Macoy Madson 2 years ago
parent
commit
56c3e72149
  1. 5
      RunValgrind.sh
  2. 2
      src/Export.cake
  3. 5
      src/FileHelper.cake

5
RunValgrind.sh

@ -17,4 +17,7 @@ $CAKELISP --verbose-processes \
src/Config_Linux.cake \
src/FileHelper.cake || exit $?
valgrind --leak-check=full --suppressions=ValgrindSuppression.supp ./file-helper
valgrind --leak-check=full --suppressions=ValgrindSuppression.supp \
./file-helper
# --track-fds=yes \
# --child-silent-after-fork=yes \ # Necessary for when opening File Explorer; doesn't work because output stops

2
src/Export.cake

@ -117,6 +117,7 @@
;; Children do override. More work is needed
(var child-entries (* directory-entry) null)
(dynarray-set-capacity child-entries 64)
(var error-string-buffer ([] 1024 char) (array 0))
;; Note that by this point no entry should be a file, because files never have children, so
@ -173,6 +174,7 @@
on-pure-entry on-pure-entry-userdata))
(dynarray-free entry-child-path)
(directory-entries-destroy child-entries)
(dynarray-free child-entries)
(set child-entries null))
(defun export-category-paths (entries (* directory-entry-userdata) ;; strdict

5
src/FileHelper.cake

@ -1011,9 +1011,11 @@
(imgui-call TextWrapped "Create categories to organize your files.")
(var-static open-explorer-on-export bool true)
(when (imgui-call Button "Export all to text")
(export-category-paths g-userdata-dict g-categories-dict)
(open-system-file-explorer g-userdata-output-dir))
(when open-explorer-on-export
(open-system-file-explorer g-userdata-output-dir)))
(when (imgui-call IsItemHovered)
(imgui-call BeginTooltip)
(imgui-call Text "Export a list of all files and directories in each category.")
@ -1021,6 +1023,7 @@
(imgui-call Text "A file explorer will open in the export directory.")
(imgui-call Text "You can use these files as inputs into your backup systems, for example.")
(imgui-call EndTooltip))
(imgui-call SameLine) (imgui-call Checkbox "Open Explorer on Export" (addr open-explorer-on-export))
(imgui-call Separator)

Loading…
Cancel
Save