Browse Source

GZIP defer diverging fix in gzip example.

Jeroen van Rijn 4 years ago
parent
commit
955472bd21
1 changed files with 3 additions and 2 deletions
  1. 3 2
      core/compress/gzip/example.odin

+ 3 - 2
core/compress/gzip/example.odin

@@ -21,7 +21,6 @@ TEST: []u8 = {
 main :: proc() {
 main :: proc() {
 	// Set up output buffer.
 	// Set up output buffer.
 	buf: bytes.Buffer;
 	buf: bytes.Buffer;
-	defer bytes.buffer_destroy(&buf);
 
 
 	stdout :: proc(s: string) {
 	stdout :: proc(s: string) {
 		os.write_string(os.stdout, s);
 		os.write_string(os.stdout, s);
@@ -40,6 +39,7 @@ main :: proc() {
 			stdout(bytes.buffer_to_string(&buf));
 			stdout(bytes.buffer_to_string(&buf));
 			stdout("\n");
 			stdout("\n");
 		}
 		}
+		bytes.buffer_destroy(&buf);
 	}
 	}
 
 
 	// The rest are all files.
 	// The rest are all files.
@@ -62,9 +62,10 @@ main :: proc() {
 				os.exit(1);
 				os.exit(1);
 			}
 			}
 			stderr("GZIP returned an error.\n");
 			stderr("GZIP returned an error.\n");
+				bytes.buffer_destroy(&buf);
 			os.exit(2);
 			os.exit(2);
 		}
 		}
 		stdout(bytes.buffer_to_string(&buf));
 		stdout(bytes.buffer_to_string(&buf));
 	}
 	}
-	os.exit(0);
+	bytes.buffer_destroy(&buf);
 }
 }