2 * This file is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2,
4 * as published by the Free Software Foundation.
6 * In addition to the permissions in the GNU General Public License,
7 * the authors give you unlimited permission to link the compiled
8 * version of this file into combinations with other programs,
9 * and to distribute those combinations without any restriction
10 * coming from the use of this file. (The General Public License
11 * restrictions do apply in other respects; for example, they cover
12 * modification of the file, and distribution when not linked into
13 * a combined executable.)
15 * This file is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
34 git_hash_ctx
*git_hash_new_ctx(void)
36 git_hash_ctx
*ctx
= git__malloc(sizeof(*ctx
));
46 void git_hash_free_ctx(git_hash_ctx
*ctx
)
51 void git_hash_init(git_hash_ctx
*ctx
)
57 void git_hash_update(git_hash_ctx
*ctx
, const void *data
, size_t len
)
60 SHA1_Update(&ctx
->c
, data
, len
);
63 void git_hash_final(git_oid
*out
, git_hash_ctx
*ctx
)
66 SHA1_Final(out
->id
, &ctx
->c
);
69 void git_hash_buf(git_oid
*out
, const void *data
, size_t len
)
74 SHA1_Update(&c
, data
, len
);
75 SHA1_Final(out
->id
, &c
);
78 void git_hash_vec(git_oid
*out
, git_buf_vec
*vec
, size_t n
)
84 for (i
= 0; i
< n
; i
++)
85 SHA1_Update(&c
, vec
[i
].data
, vec
[i
].len
);
86 SHA1_Final(out
->id
, &c
);