mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Fixed os_linux and os_x read_entire_file function not null-terminating data.
This commit is contained in:
+2
-1
@@ -146,13 +146,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
|
|||||||
|
|
||||||
// We have a file size!
|
// We have a file size!
|
||||||
|
|
||||||
data := new_slice(u8, size);
|
data := new_slice(u8, size+1);
|
||||||
if data.data == nil {
|
if data.data == nil {
|
||||||
fmt.println("Failed to allocate file buffer.");
|
fmt.println("Failed to allocate file buffer.");
|
||||||
return nil, false;
|
return nil, false;
|
||||||
}
|
}
|
||||||
|
|
||||||
read(handle, data);
|
read(handle, data);
|
||||||
|
data[size] = 0;
|
||||||
|
|
||||||
return data, true;
|
return data, true;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -150,13 +150,14 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
|
|||||||
|
|
||||||
// We have a file size!
|
// We have a file size!
|
||||||
|
|
||||||
data := new_slice(u8, size);
|
data := new_slice(u8, size+1);
|
||||||
if data.data == nil {
|
if data.data == nil {
|
||||||
fmt.println("Failed to allocate file buffer.");
|
fmt.println("Failed to allocate file buffer.");
|
||||||
return nil, false;
|
return nil, false;
|
||||||
}
|
}
|
||||||
|
|
||||||
read(handle, data);
|
read(handle, data);
|
||||||
|
data[size] = 0;
|
||||||
|
|
||||||
return data, true;
|
return data, true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user