]> git.proxmox.com Git - libgit2.git/blobdiff - src/oid.c
push: remove own copy of callbacks
[libgit2.git] / src / oid.c
index b640cadd14ee78e0ce79f1e453390ae05615489a..9fe2ebb6522e19a0af083c609aba330ca1e162b9 100644 (file)
--- a/src/oid.c
+++ b/src/oid.c
@@ -8,6 +8,7 @@
 #include "common.h"
 #include "git2/oid.h"
 #include "repository.h"
+#include "global.h"
 #include <string.h>
 #include <limits.h>
 
@@ -99,6 +100,13 @@ void git_oid_pathfmt(char *str, const git_oid *oid)
                str = fmt_one(str, oid->id[i]);
 }
 
+char *git_oid_tostr_s(const git_oid *oid)
+{
+       char *str = GIT_GLOBAL->oid_fmt;
+       git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid);
+       return str;
+}
+
 char *git_oid_allocfmt(const git_oid *oid)
 {
        char *str = git__malloc(GIT_OID_HEXSZ + 1);
@@ -203,7 +211,7 @@ int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len)
 
 int git_oid_strcmp(const git_oid *oid_a, const char *str)
 {
-       const unsigned char *a = oid_a->id;
+       const unsigned char *a;
        unsigned char strval;
        int hexval;
 
@@ -253,7 +261,7 @@ struct git_oid_shorten {
 
 static int resize_trie(git_oid_shorten *self, size_t new_size)
 {
-       self->nodes = git__realloc(self->nodes, new_size * sizeof(trie_node));
+       self->nodes = git__reallocarray(self->nodes, new_size, sizeof(trie_node));
        GITERR_CHECK_ALLOC(self->nodes);
 
        if (new_size > self->size) {