1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 #ifndef INCLUDE_git_strarray_h__
8 #define INCLUDE_git_strarray_h__
9 
10 #include "common.h"
11 
12 /**
13  * @file git2/strarray.h
14  * @brief Git string array routines
15  * @defgroup git_strarray Git string array routines
16  * @ingroup Git
17  * @{
18  */
19 GIT_BEGIN_DECL
20 
21 /** Array of strings */
22 typedef struct git_strarray {
23 	char **strings;
24 	size_t count;
25 } git_strarray;
26 
27 /**
28  * Close a string array object
29  *
30  * This method should be called on `git_strarray` objects where the strings
31  * array is allocated and contains allocated strings, such as what you
32  * would get from `git_strarray_copy()`.  Not doing so, will result in a
33  * memory leak.
34  *
35  * This does not free the `git_strarray` itself, since the library will
36  * never allocate that object directly itself (it is more commonly embedded
37  * inside another struct or created on the stack).
38  *
39  * @param array git_strarray from which to free string data
40  */
41 GIT_EXTERN(void) git_strarray_free(git_strarray *array);
42 
43 /**
44  * Copy a string array object from source to target.
45  *
46  * Note: target is overwritten and hence should be empty, otherwise its
47  * contents are leaked.  Call git_strarray_free() if necessary.
48  *
49  * @param tgt target
50  * @param src source
51  * @return 0 on success, < 0 on allocation failure
52  */
53 GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
54 
55 
56 /** @} */
57 GIT_END_DECL
58 
59 #endif
60 
61