]> git.proxmox.com Git - libgit2.git/blame - src/git/common.h
Wrap malloc and friends and report out of memory as GIT_ENOMEM
[libgit2.git] / src / git / common.h
CommitLineData
c15648cb
SP
1#ifndef INCLUDE_git_common_h__
2#define INCLUDE_git_common_h__
3
4#ifdef __cplusplus
5# define GIT_BEGIN_DECL extern "C" {
6# define GIT_END_DECL }
7#else
8 /** Start declarations in C mode */
9# define GIT_BEGIN_DECL /* empty */
10 /** End declarations in C mode */
11# define GIT_END_DECL /* empty */
12#endif
13
16a67770
SP
14/** Declare a public function exported for application use. */
15#ifdef __GNUC__
3b8ab0b9
SP
16# define GIT_EXTERN(type) extern \
17 __attribute__((visibility("default"))) \
18 type
16a67770 19#else
3b8ab0b9 20# define GIT_EXTERN(type) extern type
16a67770
SP
21#endif
22
b7c891c6
SP
23/** Declare a function as always inlined. */
24# define GIT_INLINE(type) static inline type
25
15bffce9
SP
26/** Declare a function's takes printf style arguments. */
27#ifdef __GNUC__
28# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
29#else
30# define GIT_FORMAT_PRINTF(a,b) /* empty */
31#endif
32
c15648cb 33/**
d1ea30c3 34 * @file git/common.h
c15648cb
SP
35 * @brief Git common platform definitions
36 * @defgroup git_common Git common platform definitions
37 * @ingroup Git
38 * @{
39 */
c15648cb 40
c15648cb
SP
41/** Operation completed successfully. */
42#define GIT_SUCCESS 0
43
44/**
45 * Operation failed, with unspecified reason.
46 * This value also serves as the base error code; all other
47 * error codes are subtracted from it such that all errors
48 * are < 0, in typical POSIX C tradition.
49 */
50#define GIT_ERROR -1
51
52/** Input was not a properly formatted Git object id. */
53#define GIT_ENOTOID (GIT_ERROR - 1)
54
55/** Input does not exist in the scope searched. */
56#define GIT_ENOTFOUND (GIT_ERROR - 2)
57
64a47c01
SP
58/** Not enough space available. */
59#define GIT_ENOMEM (GIT_ERROR - 3)
60
16a67770
SP
61GIT_BEGIN_DECL
62
06160502 63/** A revision traversal pool. */
1b9e92c7 64typedef struct git_revpool git_revpool;
06160502 65
c15648cb
SP
66/** @} */
67GIT_END_DECL
68#endif