struct webnet_cgi_item
{
const char* name;
void (*handler)(struct webnet_session* session);
};
static struct webnet_cgi_item* _cgi_items = RT_NULL;
void webnet_cgi_register(const char* name, void (*handler)(struct webnet_session* session))
{
if (_cgi_items == RT_NULL)
{
_cgi_count = 1;
_cgi_items = (struct webnet_cgi_item*) wn_malloc (sizeof(struct webnet_cgi_item) * _cgi_count);
}
else
{
_cgi_count += 1;
_cgi_items = (struct webnet_cgi_item*) wn_realloc (_cgi_items, sizeof(struct webnet_cgi_item) * _cgi_count);
}
RT_ASSERT(_cgi_items != RT_NULL);
_cgi_items[_cgi_count - 1].name = name;
_cgi_items[_cgi_count - 1].handler = handler;
}
读代码1 -realloc
最新推荐文章于 2022-09-25 20:30:51 发布