new, new_slice, delete

This commit is contained in:
Ginger Bill
2016-08-28 01:06:42 +01:00
parent ae75ab169b
commit 593563d8ea
8 changed files with 348 additions and 140 deletions
+4 -4
View File
@@ -75,8 +75,8 @@ read_entire_file :: proc(name: string) -> (string, bool) {
return "", false;
}
data: ^u8 = alloc(length as int);
if data == null {
data := new_slice(u8, length);
if ^data[0] == null {
return "", false;
}
@@ -95,12 +95,12 @@ read_entire_file :: proc(name: string) -> (string, bool) {
ReadFile(f.handle as HANDLE, ^data[total_read], to_read, ^single_read_length, null);
if single_read_length <= 0 {
dealloc(data);
delete(data);
return "", false;
}
total_read += single_read_length as i64;
}
return data[:length] as string, true;
return data as string, true;
}