Skip to content

Commit b5554b9

Browse files
committed
sampling : fix malloc
ggml-ci
1 parent 0d96efa commit b5554b9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

common/sampling.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include "sampling.h"
22

33
struct llama_sampling_context * llama_sampling_init(const struct gpt_params & params) {
4-
struct llama_sampling_context * result =
5-
(struct llama_sampling_context *) malloc(sizeof(struct llama_sampling_context));
4+
struct llama_sampling_context * result = new llama_sampling_context();
65

76
result->params = params.sampling_params;
87
result->grammar = nullptr;
@@ -34,7 +33,7 @@ void llama_sampling_free(struct llama_sampling_context * ctx) {
3433
llama_grammar_free(ctx->grammar);
3534
}
3635

37-
free(ctx);
36+
delete ctx;
3837
}
3938

4039
void llama_sampling_reset(llama_sampling_context * ctx) {

0 commit comments

Comments
 (0)