Fixed os_linux and os_x read_entire_file function not null-terminating data.

This commit is contained in:
Zac Pierson
2017-03-21 16:00:11 -05:00
parent 690c682847
commit e935f8e2ff
2 changed files with 4 additions and 2 deletions

View File

@@ -146,13 +146,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
// We have a file size!
data := new_slice(u8, size);
data := new_slice(u8, size+1);
if data.data == nil {
fmt.println("Failed to allocate file buffer.");
return nil, false;
}
read(handle, data);
data[size] = 0;
return data, true;
}

View File

@@ -150,13 +150,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
// We have a file size!
data := new_slice(u8, size);
data := new_slice(u8, size+1);
if data.data == nil {
fmt.println("Failed to allocate file buffer.");
return nil, false;
}
read(handle, data);
data[size] = 0;
return data, true;
}