interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / odb / source-inmemory.h

35 lines · 1143 bytes Raw Blame History
1#ifndef ODB_SOURCE_INMEMORY_H
2#define ODB_SOURCE_INMEMORY_H
3
4#include "odb/source.h"
5
6struct oidtree;
7
8/*
9 * An in-memory source that you can write objects to that shall be made
10 * available for reading, but that shouldn't ever be persisted to disk. Note
11 * that any objects written to this source will be stored in memory, so the
12 * number of objects you can store is limited by available system memory.
13 */
14struct odb_source_inmemory {
15 struct odb_source base;
16 struct oidtree *objects;
17};
18
19/* Create a new in-memory object database source. */
20struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb);
21
22/*
23 * Cast the given object database source to the in-memory backend. This will
24 * cause a BUG in case the source doesn't use this backend.
25 */
26static inline struct odb_source_inmemory *odb_source_inmemory_downcast(struct odb_source *source)
27{
28 if (source->type != ODB_SOURCE_INMEMORY)
29 BUG("trying to downcast source of type '%s' to '%s'",
30 odb_source_type_to_name(source->type),
31 odb_source_type_to_name(ODB_SOURCE_INMEMORY));
32 return container_of(source, struct odb_source_inmemory, base);
33}
34
35#endif