]> git.proxmox.com Git - libgit2.git/blob - script/user_nodefs.h
New upstream version 1.3.0+dfsg.1
[libgit2.git] / script / user_nodefs.h
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
8 #nodef GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { __coverity_panic__(); }
9 #nodef GIT_ERROR_CHECK_ALLOC_BUF(buf) if (buf == NULL || git_buf_oom(buf)) { __coverity_panic__(); }
10
11 #nodef GITERR_CHECK_ALLOC_ADD(out, one, two) \
12 if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { __coverity_panic__(); }
13
14 #nodef GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
15 if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
16 GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { __coverity_panic__(); }
17
18 #nodef GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
19 if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
20 GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
21 GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { __coverity_panic__(); }
22
23 #nodef GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
24 if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { __coverity_panic__(); }
25
26 #nodef GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) { __coverity_panic__(); }
27
28 #nodef LOOKS_LIKE_DRIVE_PREFIX(S) (strlen(S) >= 2 && git__isalpha((S)[0]) && (S)[1] == ':')
29
30 #nodef git_vector_foreach(v, iter, elem) \
31 for ((iter) = 0; (v)->contents != NULL && (iter) < (v)->length && ((elem) = (v)->contents[(iter)], 1); (iter)++ )
32
33 #nodef git_vector_rforeach(v, iter, elem) \
34 for ((iter) = (v)->length - 1; (v)->contents != NULL && (iter) < SIZE_MAX && ((elem) = (v)->contents[(iter)], 1); (iter)-- )