summaryrefslogtreecommitdiff
path: root/src/repository.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-02-28 16:51:17 +0200
committerVicent Marti <tanoku@gmail.com>2011-03-03 20:23:52 +0200
commit48c27f86bbe9678c7e01a90a2cec7a30327b0e90 (patch)
tree0156ea823de82477792ad4778378200eee28aee3 /src/repository.h
parent86d7e1ca6f54161a9e4d1ebe7a2f8e4802dc9639 (diff)
downloadlibgit2-48c27f86bbe9678c7e01a90a2cec7a30327b0e90.tar.gz
Implement reference counting for git_objects
All `git_object` instances looked up from the repository are reference counted. User is expected to use the new `git_object_close` when an object is no longer needed to force freeing it. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/repository.h')
-rw-r--r--src/repository.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/repository.h b/src/repository.h
index c8e4186b3..2e8d187b0 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -15,6 +15,8 @@
#define GIT_OBJECTS_DIR "objects/"
#define GIT_INDEX_FILE "index"
+#define GIT_OBJECT_INCREF(ob) ++(((git_object *)(ob))->refcount)
+
typedef struct {
git_rawobj raw;
void *write_ptr;
@@ -26,13 +28,16 @@ struct git_object {
git_oid id;
git_repository *repo;
git_odb_source source;
- int in_memory:1, modified:1;
+ unsigned short refcount;
+ short in_memory:1, modified:1;
};
struct git_repository {
git_odb *db;
git_index *index;
+
git_hashtable *objects;
+ git_vector memory_objects;
git_refcache references;
@@ -47,6 +52,10 @@ struct git_repository {
int git_object__source_open(git_object *object);
void git_object__source_close(git_object *object);
+/* fully free the object; internal method, do not
+ * export */
+void git_object__free(git_object *object);
+
int git__source_printf(git_odb_source *source, const char *format, ...);
int git__source_write(git_odb_source *source, const void *bytes, size_t len);