假设我有以下功能:
Table * lookup_set(Table * t, char * key, ValueType value)
{
int hash = lookup_hash(key);
char * key_copy = strdup(key);
Entry * bucket = t->table[hash];
...
然后稍后
Entry * new = (Entry *) malloc(sizeof(Entry));
new->key = key_copy;
new->value = value;
new->next = NULL;
bucket = new;
return t;
}
t->table[hash] 的值不会更改为 new,即使我将 new 分配给 bucket,我认为我将它设置为指向 t->table[hash] 指向的内存块。我究竟做错了什么?