... and that doesn't necessarily mean that malloc() failed.
We do *not* want to evict a heavy-hitter by an unfrequent element.
Note: even the implementation currently in master *did* return NULL,
so some parts of the code were just wrongly returning ENOMEM.
}
struct cookie_opt_data *cached = lru_get_new(cache, addr, addr_len);
- if (!cached) {
- return kr_error(ENOMEM);
+ if (cached) {
+ memcpy(cached->opt_data, opt, opt_size);
}
- memcpy(cached->opt_data, opt, opt_size);
-
return kr_ok();
}
}
unsigned *cur = lru_get_new(cache, addr_in, addr_len);
if (!cur) {
- return kr_error(ENOMEM);
+ return kr_ok();
}
/* Score limits */
if (score > KR_NS_MAX_SCORE) {
ns->reputation = reputation;
/* Store reputation in the LRU cache */
unsigned *cur = lru_get_new(cache, (const char *)ns->name, knot_dname_size(ns->name));
- if (!cur) {
- return kr_error(ENOMEM);
+ if (cur) {
+ *cur = reputation;
}
- *cur = reputation;
return kr_ok();
}
for (i = 0; i < dict_size; i++) {
int *data = lru_get_new(lru, dict[i], KEY_LEN(dict[i]));
- assert_non_null(data);
+ if (!data) {
+ continue;
+ }
*data = i;
assert_true(*lru_get_try(lru, dict[i], KEY_LEN(dict[i])) == i);
}
test_randstr(key, sizeof(key));
int *data = lru_get_new(lru, key, sizeof(key));
if (!data) {
- assert_true(0);
+ continue;
}
*data = i;
if (*lru_get_try(lru, key, sizeof(key)) != i) {