Correct loop range for gguf_remove_key and code format

This commit is contained in:
z5269887 2024-04-11 21:26:19 +08:00
parent 29ed5d60e1
commit ad0710aa8b

3
ggml.c
View file

@ -21152,8 +21152,9 @@ void gguf_remove_key(struct gguf_context * ctx, const char * key) {
const int idx = gguf_find_key(ctx, key);
if (idx >= 0) {
const int n_kv = gguf_get_n_kv(ctx);
for (int i = idx; i < n_kv; ++i)
for (int i = idx; i < n_kv-1; ++i) {
ctx->kv[i] = ctx->kv[i+1];
}
ctx->kv = realloc(ctx->kv, (n_kv - 1) * sizeof(struct gguf_kv));
ctx->header.n_kv--;
}