I'm developing a Python module in C that parses a very efficient protocol which uses dynamic integer sizes. Integers sent using this protocol can range in size from the equivalent of C's 'short' to a 'long long.'
The protocol has a byte that specifies the type of variable being sent (from short to long long), but I'm not sure how to deal with this in code. Right now, I'm setting up a void pointer and allocating memory in the size of the value being sent -- then using atoi, atol, and atoll to set that pointer. The problem is, I need to be able to access that value, and am unable to do so without it being cast later.
What are some good ways to handle this issue?