Merge pull request #972 from PaulThompson/separate_strarray Separated git_strarray from common.h. Added doxy comments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index ef3badb..a4d0a0c 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -10,7 +10,7 @@
#include "common.h"
#include "types.h"
#include "indexer.h"
-
+#include "strarray.h"
/**
* @file git2/checkout.h
diff --git a/include/git2/common.h b/include/git2/common.h
index 0af37e8..dd6909f 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -85,14 +85,6 @@ GIT_BEGIN_DECL
*/
#define GIT_PATH_MAX 4096
-typedef struct {
- char **strings;
- size_t count;
-} git_strarray;
-
-GIT_EXTERN(void) git_strarray_free(git_strarray *array);
-GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
-
/**
* Return the version of the libgit2 library
* being currently used.
@@ -128,4 +120,5 @@ GIT_EXTERN(int) git_libgit2_capabilities(void);
/** @} */
GIT_END_DECL
+
#endif
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 10b73f0..001c2bc 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -10,6 +10,7 @@
#include "common.h"
#include "types.h"
#include "oid.h"
+#include "strarray.h"
/**
* @file git2/refs.h
diff --git a/include/git2/remote.h b/include/git2/remote.h
index c015289..a40daec 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -12,6 +12,7 @@
#include "refspec.h"
#include "net.h"
#include "indexer.h"
+#include "strarray.h"
/**
* @file git2/remote.h
diff --git a/include/git2/strarray.h b/include/git2/strarray.h
new file mode 100644
index 0000000..f6092fa
--- /dev/null
+++ b/include/git2/strarray.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_strarray_h__
+#define INCLUDE_git_strarray_h__
+
+#include "common.h"
+
+/**
+ * @file git2/strarray.h
+ * @brief Git string array routines
+ * @defgroup git_strarray Git string array routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/** Array of strings */
+typedef struct _git_strarray git_strarray;
+struct _git_strarray {
+ char **strings;
+ size_t count;
+};
+
+/**
+ * Close a string array object
+ *
+ * This method must always be called once a git_strarray is no
+ * longer needed, otherwise memory will leak.
+ *
+ * @param array array to close
+ */
+GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+
+/**
+ * Copy a string array object from source to target.
+ *
+ * Note: target is overwritten and hence should be empty,
+ * otherwise its contents are leaked.
+ *
+ * @param tgt target
+ * @param src source
+ */
+GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
+
+
+/** @} */
+GIT_END_DECL
+
+#endif
+
diff --git a/include/git2/tag.h b/include/git2/tag.h
index 08504ae..5602914 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -11,6 +11,7 @@
#include "types.h"
#include "oid.h"
#include "object.h"
+#include "strarray.h"
/**
* @file git2/tag.h
diff --git a/src/buffer.h b/src/buffer.h
index 94b7e0e..2aae06c 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -8,6 +8,7 @@
#define INCLUDE_buffer_h__
#include "common.h"
+#include "git2/strarray.h"
#include <stdarg.h>
typedef struct {