#include "queue_mem.h" static unsigned char* node_static_buf; static unsigned int node_buf_size = 0; // static unsigned int node_buf_curr = 0; void node_set_static_buf(void* buf, unsigned int size) { node_static_buf = buf; node_buf_size = size; node_buf_curr = 0; } void* node_malloc(unsigned int size) { unsigned char* new_block; if (size + node_buf_curr <= node_buf_size) { new_block = node_static_buf + node_buf_curr; //printf("start id:%d max_size:%d ID:%d old:%d\n", node_buf_curr, node_buf_size, new_block, node_static_buf); node_buf_curr += size; return new_block; } else { //printf("-----error buff!!-------\n"); return new_block; } } void* node_mem(unsigned int size) { //void* p = node_malloc(size); void* new_block; if (size + node_buf_curr <= node_buf_size) { new_block = node_static_buf + node_buf_curr; //printf("start id:%d max_size:%d ID:%d old:%d\n", node_buf_curr, node_buf_size, new_block, node_static_buf); node_buf_curr += size; if (new_block) memset(new_block, 0, size); return new_block; } printf("Buffer error!"); return 0; }