plug in memleak in api

Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>