Browse Source

Correction to `image.destroy`

gingerBill 3 years ago
parent
commit
e8485ee7e7
2 changed files with 4 additions and 2 deletions
  1. 1 1
      core/image/common.odin
  2. 3 1
      core/image/general_loader.odin

+ 1 - 1
core/image/common.odin

@@ -57,7 +57,7 @@ Image :: struct {
 	which:         Which_File_Type,
 	which:         Which_File_Type,
 }
 }
 
 
-Image_Metadata :: union {
+Image_Metadata :: union #shared_nil {
 	^Netpbm_Info,
 	^Netpbm_Info,
 	^PNG_Info,
 	^PNG_Info,
 	^QOI_Info,
 	^QOI_Info,

+ 3 - 1
core/image/general_loader.odin

@@ -52,7 +52,9 @@ destroy :: proc(img: ^Image, allocator := context.allocator) -> bool {
 	destroyer := _internal_destroyers[img.which]
 	destroyer := _internal_destroyers[img.which]
 	if destroyer != nil {
 	if destroyer != nil {
 		destroyer(img)
 		destroyer(img)
+	} else {
+		assert(img.metadata == nil)
+		free(img)
 	}
 	}
-	free(img)
 	return true
 	return true
 }
 }