]> git.proxmox.com Git - libgit2.git/commit - src/hash.c
Wrap malloc and friends and report out of memory as GIT_ENOMEM
authorShawn O. Pearce <spearce@spearce.org>
Wed, 31 Dec 2008 07:21:36 +0000 (23:21 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 31 Dec 2008 07:28:30 +0000 (23:28 -0800)
commit64a47c01426a36cdb7e598d17018d5791e54bb97
treec96d985df9957e7c042290d868d44feed8a4fc08
parentffb55c532ccc1cb3c47eeeaac6c64240ab88fe29
Wrap malloc and friends and report out of memory as GIT_ENOMEM

We now forbid direct use of malloc, strdup or calloc within the
library and instead use wrapper functions git__malloc, etc. to
invoke the underlying library malloc and set git_errno to a no
memory error code if the allocation fails.

In the future once we have pack objects in memory we are likely
to enhance these routines with garbage collection logic to purge
cached pack data when allocations fail.  Because the size of the
function will grow somewhat large, we don't want to mark them for
inline as gcc tends to aggressively inline, creating larger than
expected executables.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
12 files changed:
src/commit.c
src/common.h
src/errors.c
src/fileops.c
src/git/common.h
src/hash.c
src/odb.c
src/oid.c
src/revwalk.c
src/thread-utils.c
src/util.c [new file with mode: 0644]
src/util.h