summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 000000000..64b5d4fbe
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,26 @@
+#define GIT__NO_HIDE_MALLOC
+#include "common.h"
+
+void *git__malloc(size_t n)
+{
+ void *r = malloc(n);
+ if (!r)
+ return git_ptr_error(GIT_ENOMEM);
+ return r;
+}
+
+void *git__calloc(size_t a, size_t b)
+{
+ void *r = calloc(a, b);
+ if (!r)
+ return git_ptr_error(GIT_ENOMEM);
+ return r;
+}
+
+char *git__strdup(const char *s)
+{
+ char *r = strdup(s);
+ if (!s)
+ return git_ptr_error(GIT_ENOMEM);
+ return r;
+}