You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The old_val pointer in the README example isn't initialized. This results in the last conditional falsely firing on some compilers.
charchar *key = strdup( *key = st "my key");
char *val = strdup("my val");
// if a caller knows the value doesn't already exist// BEWARE: using it this way can cause memory leaks!if (!rsht_put(ht, key, val, NULL)) {
// handle out of memory error
}
// if a caller wants to know the previous value and free itvoid *old_val; // Should be initialized to zeroif (!rsht_put(ht, key, val, &old_val)) {
// handle out of memory errorfree(key);
}
if (old_val) {
free(key); // if the value existed, we can free the key we just usedfree(old_val);
}
The text was updated successfully, but these errors were encountered:
The
old_val
pointer in the README example isn't initialized. This results in the last conditional falsely firing on some compilers.The text was updated successfully, but these errors were encountered: