mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
encoding.binary: little_endian_f32_at
This commit is contained in:
parent
605c43df75
commit
940fc41c19
@ -622,7 +622,6 @@ pub fn free(ptr voidptr) {
|
||||
// memdup dynamically allocates a `sz` bytes block of memory on the heap
|
||||
// memdup then copies the contents of `src` into the allocated space and
|
||||
// returns a pointer to the newly allocated space.
|
||||
|
||||
@[unsafe]
|
||||
pub fn memdup(src voidptr, sz isize) voidptr {
|
||||
$if trace_memdup ? {
|
||||
|
@ -151,3 +151,11 @@ pub fn little_endian_put_u64_at(mut b []u8, v u64, o int) {
|
||||
pub fn little_endian_put_u64_end(mut b []u8, v u64) {
|
||||
little_endian_put_u64_at(mut b, v, b.len - 8)
|
||||
}
|
||||
|
||||
@[direct_array_access; inline]
|
||||
pub fn little_endian_f32_at(b []u8, o int) f32 {
|
||||
_ = b[o] // bounds check
|
||||
_ = b[o + 3] // bounds check
|
||||
u := u32(b[o]) | (u32(b[o + 1]) << u32(8)) | (u32(b[o + 2]) << u32(16)) | (u32(b[o + 3]) << u32(24))
|
||||
return *(&f32(&u))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user