summaryrefslogtreecommitdiff
path: root/src/revobject.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-05-22 23:21:10 +0200
committerAndreas Ericsson <ae@op5.se>2010-06-02 10:32:06 +0200
commitc5696427b6d53a3f79baad35ea33c556884a410a (patch)
treecb3ab00e68da089aecd496ba4e39b1c706ed7c68 /src/revobject.h
parent36b7cdb6a1a2e685c7141406808366d4c4b9f98e (diff)
downloadlibgit2-c5696427b6d53a3f79baad35ea33c556884a410a.tar.gz
Add 'git_revpool_object' and 'git_revpool_table' structures.
All the objects which will will be eventually transversable from a revision pool (commits, trees, etc) now inherit from the 'git_revpool_object' structure which identifies them with their own OID. Furthermore, the 'git_revpool_table' and related functions have been added, which allow for constant time lookup (hash table) of the loaded revpool objects based on their OID. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/revobject.h')
-rw-r--r--src/revobject.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/revobject.h b/src/revobject.h
new file mode 100644
index 000000000..8ea17a2c5
--- /dev/null
+++ b/src/revobject.h
@@ -0,0 +1,39 @@
+#ifndef INCLUDE_objecttable_h__
+#define INCLUDE_objecttable_h__
+
+#include "git/common.h"
+#include "git/oid.h"
+
+struct git_revpool_object
+{
+ git_oid id;
+ git_revpool *pool;
+};
+
+struct git_revpool_node
+{
+ struct git_revpool_object *object;
+ unsigned int hash;
+ struct git_revpool_node *next;
+};
+
+struct git_revpool_table
+{
+ unsigned int size_mask;
+ unsigned int count;
+ unsigned int max_count;
+ struct git_revpool_node **nodes;
+};
+
+
+typedef struct git_revpool_node git_revpool_node;
+typedef struct git_revpool_object git_revpool_object;
+typedef struct git_revpool_table git_revpool_table;
+
+git_revpool_table *git_revpool_table_create(unsigned int min_size);
+int git_revpool_table_insert(git_revpool_table *table, git_revpool_object *object);
+git_revpool_object *git_revpool_table_lookup(git_revpool_table *table, const git_oid *id);
+void git_revpool_table_resize(git_revpool_table *table);
+
+
+#endif