Reputation: 25479
I'm trying to cast a struct pointer to a void**
for a function that takes a void**
;
typedef struct {
uint64_t key; // the key in the key/value pair
void *value; // the value in the key/value pair
} HTKeyValue, *HTKeyValuePtr;
HTKeyValuePtr payload = (HTKeyValuePtr)malloc(sizeof(HTKeyValue));
int success = (HTKeyValuePtr) LLIteratorGetPayload(i, (void**) &payload);
gives me the warnings:
hashtable.c:161:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
hashtable.c:161:19: warning: initialization makes integer from pointer without a cast [enabled by default]
What's going on? How do I fix this?
p.s. sorry if this is a dup of any other question. There were a lot of similar questions but I couldn't find one that fit my situation and that I understood.
Upvotes: 1
Views: 177
Reputation: 22020
int success = (HTKeyValuePtr) LLIteratorGetPayload(i, (void**) &payload);
You're assigning a pointer into an int...
In addition, google tells me the first argument to LLIteratorGetPayload
should be a LLIter
, which turns out to be a typedef void*
. I'm guessing i
is an integer. That's the reason for the first error.
Upvotes: 4