git_odb_writepack **, git_odb_backend *, git_odb *odb,
git_transfer_progress_cb progress_cb, void *progress_payload);
+ /**
+ * Frees any resources held by the odb (including the `git_odb_backend`
+ * itself). An odb backend implementation must provide this function.
+ */
void (* free)(git_odb_backend *);
};
int (*ensure_log)(git_refdb_backend *backend, const char *refname);
/**
- * Frees any resources held by the refdb. A refdb implementation may
- * provide this function; if it is not provided, nothing will be done.
+ * Frees any resources held by the refdb (including the `git_refdb_backend`
+ * itself). A refdb backend implementation must provide this function.
*/
void (*free)(git_refdb_backend *backend);
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *backend = internal->backend;
- if (backend->free) backend->free(backend);
- else git__free(backend);
+ backend->free(backend);
git__free(internal);
}
static void refdb_free_backend(git_refdb *db)
{
- if (db->backend) {
- if (db->backend->free)
- db->backend->free(db->backend);
- else
- git__free(db->backend);
- }
+ if (db->backend)
+ db->backend->free(db->backend);
}
int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
if (b == NULL)
return NULL;
+ b->base.free = (void (*)(git_odb_backend *)) git__free;
b->base.version = GIT_ODB_BACKEND_VERSION;
b->position = position;
return (git_odb_backend *)b;