blosc_compress returns the size of compressed block according to blosc.h. However, the return type is int, which has an obvious susceptibility to overflow in the common case of a 64-bit machine where int is 32 bits.
Update: Upon looking through blosc.c, it seems that 32-bit limits are found throughout the code, not just in the API. At least on 64-bit machines, it would be highly desirable to support 64-bit buffer sizes.
Ideally, you would return size_t. But this is unsigned, and I see that you want to use negative return values to indicate errors. Two possibilities:
- Return
ptrdiff_t (C90) or (in C99) intptr_t. This is a 64-bit signed value on 64-bit machines, and a 32-bit signed value on 32-bit machines.
- Return
size_t, and return an error code in some other way. errno would be the obvious way for blosc_compress. For blosc_compress_ctx one option would be to add an int *errno parameter.
blosc_compressreturns the size of compressed block according toblosc.h. However, the return type isint, which has an obvious susceptibility to overflow in the common case of a 64-bit machine whereintis 32 bits.Update: Upon looking through blosc.c, it seems that 32-bit limits are found throughout the code, not just in the API. At least on 64-bit machines, it would be highly desirable to support 64-bit buffer sizes.
Ideally, you would return
size_t. But this is unsigned, and I see that you want to use negative return values to indicate errors. Two possibilities:ptrdiff_t(C90) or (in C99)intptr_t. This is a 64-bit signed value on 64-bit machines, and a 32-bit signed value on 32-bit machines.size_t, and return an error code in some other way.errnowould be the obvious way forblosc_compress. Forblosc_compress_ctxone option would be to add anint *errnoparameter.