Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions chat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "ggml.h"

#include "utils.h"

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -561,12 +559,18 @@ bool llama_eval(

// reallocate
buf_size = buf_size_new;
buf = realloc(buf, buf_size);
if (buf == nullptr) {
fprintf(stderr, "%s: failed to allocate %zu bytes\n", __func__, buf_size);
return false;

void * tmp = realloc(buf, buf_size);
if (NULL == tmp)
{
fprintf(stderr, "%s: failed to allocate %zu bytes\n", __func__, buf_size);
return false;
}
}
else
{
buf = tmp;
}
}

struct ggml_init_params params = {
/*.mem_size =*/ buf_size,
Expand Down