I have a function like this:
uint8_t getULEB128Value(uint8_t *p, uint32_t *to){
unsigned int result;
uint8_t count = 1;
uint8_t cur;
result = *p;
if(result > 0x7F){
count++;
cur = *(++p);
result = (result & 0x7F) | (cur << 7);
if(cur > 0x7F){
count++;
cur = *(++p);
result |= ((cur & 0x7F) << 14);
if(cur > 0x7F){
count++;
cur = *(++p);
result |= ((cur & 0x7F) << 21);
if(cur > 0x7F){
count++;
cur = *(++p);
result |= ((cur & 0x7F) << 28);
}
}
}
}
*to = result;
return count;
}
Now I just want to know the length and I’m not really interested in the value…
Is it possible to have a don’t care pointer? so every value which is wrote there goes to nirvana? like /dev/null?
I mean of course I can create a pointer somewhere and free it afterwards but maybe there is a thing for that already?
The usual pattern for this is to allow passing a null pointer into your function and check this before writing the value:
Then you can call it like
when you do not want to write anything into the “to” pointer.