I can't see any real benefit of floating-point in the amount_tofree
computation; we could use round(), but it doesn't seem significant.
#include "categories.h"
#include <libknot/libknot.h>
+#include "lib/utils.h"
static bool rrtype_is_infrastructure(uint16_t r)
{
static int get_random(int to)
{
- return rand() % to;
+ // We don't need these to be really unpredictable,
+ // but this should be cheap enough not to be noticeable.
+ return kr_rand_bytes(1) % to;
}
// TODO this is just an example, make this more clever
return ret;
}
- ssize_t amount_tofree = (double)knot_db_lmdb_get_mapsize(db) * cfg->cache_to_be_freed / 100.0;
+ ssize_t amount_tofree = knot_db_lmdb_get_mapsize(db) * cfg->cache_to_be_freed / 100;
// debug
/*printf("tofree: %zd\n", amount_tofree);