Skip to content

Commit fd2b8e1

Browse files
author
Olivier Chafik
committed
use deleter functor for common_chat_templates_ptr
1 parent d2969b8 commit fd2b8e1

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

common/chat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ common_chat_templates_ptr common_chat_templates_init(
411411
token_bos = get_token(llama_vocab_bos(vocab), "BOS", "bos_token");
412412
token_eos = get_token(llama_vocab_eos(vocab), "EOS", "eos_token");
413413
}
414-
common_chat_templates_ptr tmpls(new common_chat_templates(), common_chat_templates_free);
414+
common_chat_templates_ptr tmpls(new common_chat_templates());
415415
tmpls->has_explicit_template = has_explicit_template;
416416
try {
417417
tmpls->template_default = std::make_unique<minja::chat_template>(default_template_src, token_bos, token_eos);

common/chat.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ struct common_chat_params {
8585
// Check if the template supplied via "--chat-template" is supported or not. Returns true if it's valid
8686
bool common_chat_verify_template(const std::string & tmpl, bool use_jinja);
8787

88-
8988
void common_chat_templates_free(struct common_chat_templates * tmpls);
90-
typedef std::unique_ptr<struct common_chat_templates, decltype(&common_chat_templates_free)> common_chat_templates_ptr;
89+
90+
struct common_chat_templates_deleter { void operator()(common_chat_templates * tmpls) { common_chat_templates_free(tmpls); } };
91+
92+
typedef std::unique_ptr<struct common_chat_templates, common_chat_templates_deleter> common_chat_templates_ptr;
9193

9294
common_chat_templates_ptr common_chat_templates_init(
9395
const struct llama_model * model,

examples/server/server.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,6 @@ struct server_context {
18061806

18071807
common_chat_templates_ptr chat_templates;
18081808

1809-
server_context() : chat_templates(nullptr, nullptr) {}
1810-
18111809
~server_context() {
18121810
// Clear any sampling context
18131811
for (server_slot & slot : slots) {

0 commit comments

Comments
 (0)