tdb: add proper OOM/ENOSPC handling to tdb_expand()