Jump to content

3ndal1s

Members
  • Posts

    2
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Everything posted by 3ndal1s

  1. i'm adding here the results of my research on operator precedence: 1.-> selection of a member of the pointed variable 2.* pointer dereference 3.(typeID) casting in C-style 4.<< bitwise left shift 5.|= bitwise OR and assignment
  2. Hello i'm a C++ newbie and i am starting my exploration of mangos sourcecode. The first files i tried to read have been some /libmpq/ sources, huffman.cpp in particular. I don't really understand a statement in that file, can someone explain it to me with some patience? The line of interest lies within a function called libmpq_huff_get_8bits: static unsigned long libmpq_huff_get_8bits(struct huffman_input_stream *is) { unsigned long one_byte; if (is->bits <= 8) { is->bit_buf |= *(unsigned short *)is->in_buf << is->bits; is->in_buf += sizeof(unsigned short); is->bits += 16; } one_byte = (is->bit_buf & 0xFF); is->bit_buf >>= 8; is->bits -= 8; return one_byte; } this function takes on a huffman_input_stream * pointer as a parameter. This struct is declared in huffman.h as it follows: struct huffman_input_stream { unsigned char *in_buf; /* 00 - Input data */ unsigned long bit_buf; /* 04 - Input bit buffer */ unsigned int bits; /* 08 - Number of bits remaining in 'byte' */ }; so now let's get to the point i'm missing: is->bit_buf |= *(unsigned short *)is->in_buf << is->bits; What does this line do exactly? Anticipated thanks for the ones who will answer me and my apologies if i committed any mistakes in posting this question here.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use