thresholds lib - use xmalloc instead of malloc

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>