add length_prefix_array_map_8_to_8

This commit is contained in:
Michael Sippel 2025-02-20 05:16:31 +01:00
parent d6107601a6
commit b88251b9c4
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 24 additions and 9 deletions
morphisms
src

View file

@ -63,3 +63,8 @@ int length_prefix_array_map_64_to_8(
struct LengthPrefixUInt64Array const * restrict src,
struct LengthPrefixUInt8Array * restrict dst
);
int length_prefix_array_map_8_to_8(
int (*f) ( uint8_t const * restrict, uint8_t * restrict ),
struct LengthPrefixUInt8Array const * restrict src,
struct LengthPrefixUInt8Array * restrict dst
);

View file

@ -28,6 +28,21 @@ int length_prefix_uint64_array_reverse(
return 0;
}
int length_prefix_array_map_8_to_8(
int (*f) ( uint8_t const * restrict, uint8_t * restrict ),
struct LengthPrefixUInt8Array const * restrict src,
struct LengthPrefixUInt8Array * restrict dst
) {
dst->len = src->len;
for( uint64_t i = 0; i < src->len; ++i ) {
int result = f( &src->items[i], &dst->items[i] );
if( result ) {
return result;
}
}
return 0;
}
int length_prefix_array_map_64_to_64(
int (*f) ( uint64_t const * restrict, uint64_t * restrict ),
struct LengthPrefixUInt64Array const * restrict src,

View file

@ -197,15 +197,10 @@ impl LdmcMorphism {
let dst_c_type = get_c_repr_type(dict, self.get_type().dst_type, true).expect("cant get c-repr type for dst type");
let map_fn = match (src_c_type.as_str(), dst_c_type.as_str()) {
("struct LengthPrefixUInt64Array", "struct LengthPrefixUInt64Array") => {
"length_prefix_array_map_64_to_64"
},
("struct LengthPrefixUInt8Array", "struct LengthPrefixUInt64Array") => {
"length_prefix_array_map_8_to_64"
},
("struct LengthPrefixUInt64Array", "struct LengthPrefixUInt8Array") => {
"length_prefix_array_map_64_to_8"
},
("struct LengthPrefixUInt64Array", "struct LengthPrefixUInt64Array") => "length_prefix_array_map_64_to_64",
("struct LengthPrefixUInt8Array", "struct LengthPrefixUInt64Array") => "length_prefix_array_map_8_to_64",
("struct LengthPrefixUInt64Array", "struct LengthPrefixUInt8Array") => "length_prefix_array_map_64_to_8",
("struct LengthPrefixUInt8Array", "struct LengthPrefixUInt8Array") => "length_prefix_array_map_8_to_8",
_ => {
"{{ ERROR: no map function implemented }}"
}