Skip to content

Commit

Permalink
Change blosc2.c:set_values to always call memcpy if BLOSC_STRICT_ALIGN
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Feb 12, 2024
1 parent fd6ec1f commit db583eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions blosc/blosc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,18 @@ static int32_t set_nans(int32_t typesize, uint8_t* dest, int32_t destsize) {


static int32_t set_values(int32_t typesize, const uint8_t* src, uint8_t* dest, int32_t destsize) {
#if defined(BLOSC_STRICT_ALIGN)
if (destsize % typesize != 0) {
BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
}
int32_t nitems = destsize / typesize;
if (nitems == 0) {
return 0;
}
for (int i = 0; i < nitems; i++) {
memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
}
#else
// destsize can only be a multiple of typesize
int64_t val8;
int64_t* dest8;
Expand Down Expand Up @@ -1546,6 +1558,7 @@ static int32_t set_values(int32_t typesize, const uint8_t* src, uint8_t* dest, i
memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
}
}
#endif

return nitems;
}
Expand Down

0 comments on commit db583eb

Please sign in to comment.