修复部分bug,添加内存池,为后续内存池化分配打基础

This commit is contained in:
2026-02-18 14:46:33 +08:00
parent 19e0392db6
commit b23828cd5c
8 changed files with 224 additions and 4 deletions

View File

@ -5,11 +5,12 @@
#include <sys/socket.h>
#include <fcntl.h>
#include <errno.h>
#include <netinet/in.h>
#include "errno.h"
#include "tools/log/log.h"
#include "http_rel.h"
#include <netinet/in.h>
int write_in_bk(char input,httpbuf* blk){
if(blk->size%HTTP_BLOCK_SIZE == 0)//块满分配新块

View File

@ -33,6 +33,8 @@ static void safe_strcpy(char *dst, size_t dst_size, const char *src)
/* 主解析 */
int rbt_parse_json(const char *json_text, rbt_msg *out)
{
if(json_text == NULL)
return -1;
memset(out, 0, sizeof(*out)); // 统一清 0gid 天然 '\0'
cJSON *root = cJSON_Parse(json_text);
@ -108,7 +110,7 @@ int process_message(char *req, log_manager *logger,rbt_msg *swap) {
make_swap(swap);
logger->in_log(log, logger);
}
//通知前端已收到消息
const char *response =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/plain\r\n"

17
c/network/protocal.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef PROTOCAL
#define PROTOCAL
typedef struct network_pakage
{
char *data;
int buf_block;
}network_package;
typedef struct net_protocal
{
void *protocal;
int (*init)(void *self);
int (*rev_message)(void *self,network_package *data);
}net_protocal;
#endif