Commit Graph

53 Commits

Author SHA1 Message Date
Shawn O. Pearce
2c4b7707f7 Add git__fmt as an easier to use snprintf
Checking the return value of snprintf is a pain, as it must be
>= 0 and < sizeof(buffer).  git__fmt is a simple wrapper to
perform these checks.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-31 16:06:48 -08:00
Shawn O. Pearce
9eb7976448 Add string utility functions for prefix and suffix compares
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-31 14:35:39 -08:00
Shawn O. Pearce
64a47c0142 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>
2008-12-30 23:28:30 -08:00