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 * Free the strings contained in a string array. This method should 29 * be called on `git_strarray` objects that were provided by the 30 * library. Not doing so, will result in a memory leak. 31 * 32 * This does not free the `git_strarray` itself, since the library will 33 * never allocate that object directly itself. 34 * 35 * @param array The git_strarray that contains strings to free 36 */ 37 GIT_EXTERN(void) git_strarray_dispose(git_strarray *array); 38 39 /** 40 * Copy a string array object from source to target. 41 * 42 * Note: target is overwritten and hence should be empty, otherwise its 43 * contents are leaked. Call git_strarray_free() if necessary. 44 * 45 * @param tgt target 46 * @param src source 47 * @return 0 on success, < 0 on allocation failure 48 */ 49 GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); 50 51 52 /** @} */ 53 GIT_END_DECL 54 55 #endif 56 57