Blame include/git2/strarray.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_strarray_h__
Packit ae9e2a
#define INCLUDE_git_strarray_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/strarray.h
Packit ae9e2a
 * @brief Git string array routines
Packit ae9e2a
 * @defgroup git_strarray Git string array routines
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/** Array of strings */
Packit ae9e2a
typedef struct git_strarray {
Packit ae9e2a
	char **strings;
Packit ae9e2a
	size_t count;
Packit ae9e2a
} git_strarray;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Close a string array object
Packit ae9e2a
 *
Packit ae9e2a
 * This method should be called on `git_strarray` objects where the strings
Packit ae9e2a
 * array is allocated and contains allocated strings, such as what you
Packit ae9e2a
 * would get from `git_strarray_copy()`.  Not doing so, will result in a
Packit ae9e2a
 * memory leak.
Packit ae9e2a
 *
Packit ae9e2a
 * This does not free the `git_strarray` itself, since the library will
Packit ae9e2a
 * never allocate that object directly itself (it is more commonly embedded
Packit ae9e2a
 * inside another struct or created on the stack).
Packit ae9e2a
 *
Packit ae9e2a
 * @param array git_strarray from which to free string data
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Copy a string array object from source to target.
Packit ae9e2a
 *
Packit ae9e2a
 * Note: target is overwritten and hence should be empty, otherwise its
Packit ae9e2a
 * contents are leaked.  Call git_strarray_free() if necessary.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tgt target
Packit ae9e2a
 * @param src source
Packit ae9e2a
 * @return 0 on success, < 0 on allocation failure
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
Packit ae9e2a
#endif
Packit ae9e2a