aleshaleksey/TGWM 15

A personal etude into rust software (RPG<-it's more fun to debug) development: Tales of the Great White Moose

aleshaleksey/AZDice 10

A tool of generating and viewing dice roll success distributions.

aleshaleksey/asbestos-test 0

A simple tool for distinguishing asbestos types and detecting asbestos in IR spectra. Developed collaboratively with Vladimir Zholobenko of Keele University.

aleshaleksey/libazdice 0

A mini-dice rolling library for use in "AZDice" and similar dice rollers and distribution simulators.

aleshaleksey/libchmq 0

A library for "random" chemical calculations.

GiGainfosystems/diesel-logger 0

Times and logs queries executed by diesel

issue openedequinor/segyio

`bswap24vec` related question.

This is not so much a problem as a "Hmm, that's funny. Maybe I'll learn something if I ask a question" kind of issue.

So there are a bunch of functions: bswap64vec, bswap32vec, bswap24vec and bswap16vec. in "lib/src/segy.c" (approximately lines 1778), which is fine. I was looking at them and noticed that bswap24vec was a little bit (no pun intended) odd. Obviously in "normal" computing 24-bit (3-byte) numerical types are something of a unicorn, so that explains why the bswap24vec function is different from the rest of the bswap functions (aka 24-bit (3-byte) numerical types are not particularly "standard").

However, here we have the use of sizeof(int_whatever_t) which returns the number of bytes for int_whatever_t in most of the functions, (which would be 2, 4 and 8 for int16_t, int32_t and int64_t respectively according to C Playground), but a straight up "24" is used in bswap24vec which is the bit count and not the byte count.

So in ( char* xs = begin; xs != end; xs += sizeof(int32_t) I believe the pointer is being incremented by 4 bytes each time, while in (char* xs = begin; xs != end; xs += 24) it is being incremented by 24? Is this Ok? Does bswap24vec end up skipping a bunch of bytes? If not, would someone be able to point me to what I am misunderstanding (yes, everything, of course, but...).

static int bswap32vec( void* vec, long long len ) {
    char* begin = (char*) vec;
    char* end = (char*) begin + len * sizeof(int32_t);

    for( char* xs = begin; xs != end; xs += sizeof(int32_t) ) {
        uint32_t v;
        memcpy( &v, xs, sizeof(int32_t) );
        v = bswap32( v );
        memcpy( xs, &v, sizeof(int32_t) );

    return SEGY_OK;

static int bswap24vec( void* vec, long long len ) {
    char* begin = (char*) vec;
    char* end = (char*) begin + len * 24;

    for (char* xs = begin; xs != end; xs += 24) {
        uint8_t bits[3];
        memcpy(bits, xs, sizeof(bits));
        uint8_t tmp = bits[0];
        bits[0] = bits[2];
        bits[2] = tmp;
        memcpy(xs, bits, sizeof(bits));

    return SEGY_OK;

Again, I would like to apologise for wasting your time if I am misunderstanding the nature of the code here.

created time in 3 months