Fix struct #packed alignment calculation

This commit is contained in:
Ginger Bill
2017-08-12 20:04:35 +01:00
parent d7bd3f8402
commit 4262c125c5
4 changed files with 18 additions and 9 deletions
+10
View File
@@ -1,5 +1,15 @@
import "mem.odin";
adler32 :: proc(data: []u8) -> u32 {
ADLER_CONST :: 65521;
a, b: u32 = 1, 0;
for x in data {
a = (a + u32(x)) % ADLER_CONST;
b = (b + a) % ADLER_CONST;
}
return (b << 16) | a;
}
crc32 :: proc(data: []u8) -> u32 {
result := ~u32(0);
for b in data {
+1 -1
View File
@@ -38,7 +38,7 @@ read_entire_file :: proc(name: string) -> (data: []u8, success: bool) {
}
write_entire_file :: proc(name: string, data: []u8) -> (sucess: bool) {
fd, err := open(name, O_WRONLY, 0);
fd, err := open(name, O_WRONLY|O_CREAT, 0);
if err != 0 {
return false;
}