]>
git.proxmox.com Git - libgit2.git/blob - tests/buf/oom.c
1 #include "clar_libgit2.h"
4 #if defined(GIT_ARCH_64)
5 #define TOOBIG 0xffffffffffffff00
7 #define TOOBIG 0xffffff00
11 * If we make a ridiculously large request the first time we
12 * actually allocate some space in the git_buf, the realloc()
13 * will fail. And because the git_buf_grow() wrapper always
14 * sets mark_oom, the code in git_buf_try_grow() will free
15 * the internal buffer and set it to git_buf__oom.
17 * We initialized the internal buffer to (the static variable)
18 * git_buf__initbuf. The purpose of this test is to make sure
19 * that we don't try to free the static buffer.
21 void test_buf_oom__grow(void)
23 git_buf buf
= GIT_BUF_INIT
;
27 cl_assert(git_buf_grow(&buf
, TOOBIG
) == -1);
28 cl_assert(git_buf_oom(&buf
));