mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-15 17:25:27 +00:00
Merge pull request #1760 from Kelimion/xxh3_fix
[xxh3] Fix flaws in streaming implementation
This commit is contained in:
@@ -52,9 +52,6 @@ XXH3_128_reset_with_seed :: proc(state: ^XXH3_state, seed: XXH64_hash) -> (err:
|
||||
XXH3_64_reset_with_seed :: XXH3_128_reset_with_seed
|
||||
|
||||
XXH3_128_update :: proc(state: ^XXH3_state, input: []u8) -> (err: Error) {
|
||||
if len(input) < XXH3_MIDSIZE_MAX {
|
||||
return .Error
|
||||
}
|
||||
return XXH3_update(state, input, XXH3_accumulate_512, XXH3_scramble_accumulator)
|
||||
}
|
||||
XXH3_64_update :: XXH3_128_update
|
||||
@@ -127,6 +124,7 @@ XXH3_create_state :: proc(allocator := context.allocator) -> (res: ^XXH3_state,
|
||||
err = nil if mem_error == nil else .Error
|
||||
|
||||
XXH3_init_state(state)
|
||||
XXH3_128_reset(state)
|
||||
return state, nil
|
||||
}
|
||||
|
||||
@@ -234,7 +232,9 @@ XXH3_update :: #force_inline proc(
|
||||
*/
|
||||
if state.buffered_size > 0 {
|
||||
load_size := int(XXH3_INTERNAL_BUFFER_SIZE - state.buffered_size)
|
||||
mem_copy(&state.buffer[state.buffered_size], &input[0], load_size)
|
||||
|
||||
state_ptr := rawptr(uintptr(raw_data(state.buffer[:])) + uintptr(state.buffered_size))
|
||||
mem_copy(state_ptr, raw_data(input), load_size)
|
||||
input = input[load_size:]
|
||||
|
||||
XXH3_consume_stripes(
|
||||
|
||||
Reference in New Issue
Block a user