gpt4 book ai didi

c - 当 kv 超过 1 项时,kv 执行无限循环

转载 作者:行者123 更新时间:2023-11-30 16:57:35 27 4
gpt4 key购买 nike

我尝试使用 kv_t 存储一些数据但没有成功。我也尝试过例子forum.c & kv.c。当尝试创建第二个论坛线程时,forum.c 挂起,而 kv.c 崩溃。

当我向 kv 添加 1 个项目时,kv_do 将成功。添加第二项后,尝试调用 kv_do 将导致无限循环,并且数据似乎也无效。

#include "stdio.h"
int list_threads(kv_item *item, xbuf_t *reply)
{
Thread *thread = (Thread*)item->val;

xbuf_t thread_li;
xbuf_init(&thread_li);

//using sprintf-like formatting
xbuf_xcat(&thread_li,
"<li>"
"<a href='/?forum_simple/act=t/id=%llu'>%s</a> (%lu)"
"</li>",
thread->id, thread->title.ptr, thread->posts.nbr_items
);

char *pos = (char*)xbuf_findstr(reply, "<!--tpl-->");
if (pos) xbuf_insert(reply, pos, thread_li.len, thread_li.ptr);
printf("-----------listing threads------\n");
xbuf_free(&thread_li);

return 1;
}

上面的代码来自forum.c。在创建第一个论坛线程后尝试创建第二个论坛线程将挂起,因为 list_threads 函数如果无限调用。 ---------列出线程------------无限地打印在终端上

最佳答案

另一位用户最近报告(请参阅“最新”G-WAN 问题)kv_do 崩溃,它似乎与原子原语实现有关,而不是与 kv 代码有关。

一旦问题被隔离,我们将发布解决方法。

关于c - 当 kv 超过 1 项时,kv 执行无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39443479/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com