From b5554b9e0505789834fb4a21afb928722eb836dd Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 16 Oct 2023 00:09:24 +0300 Subject: [PATCH] sampling : fix malloc ggml-ci --- common/sampling.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/sampling.cpp b/common/sampling.cpp index ed636f415..426629c45 100644 --- a/common/sampling.cpp +++ b/common/sampling.cpp @@ -1,8 +1,7 @@ #include "sampling.h" struct llama_sampling_context * llama_sampling_init(const struct gpt_params & params) { - struct llama_sampling_context * result = - (struct llama_sampling_context *) malloc(sizeof(struct llama_sampling_context)); + struct llama_sampling_context * result = new llama_sampling_context(); result->params = params.sampling_params; result->grammar = nullptr; @@ -34,7 +33,7 @@ void llama_sampling_free(struct llama_sampling_context * ctx) { llama_grammar_free(ctx->grammar); } - free(ctx); + delete ctx; } void llama_sampling_reset(llama_sampling_context * ctx) {