Add ability to use custom memory management functions

Conflicts:
	tests/test-bson.c