hg-core: add safe bindings to bdiff.c
This is stacked on top of !1174 (merged) (it doesn't depend on it, but my WIP for rhg annotate depends on both).
This is stacked on top of !1174 (merged) (it doesn't depend on it, but my WIP for rhg annotate depends on both).