mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-22 04:02:59 +08:00
fix: cat free error
This commit is contained in:
4
server.c
4
server.c
@@ -147,7 +147,7 @@ static int send_all(thread_timer_t *timer) {
|
|||||||
off_t len = 0, file_size = get_dict_size();
|
off_t len = 0, file_size = get_dict_size();
|
||||||
char* buf = (char*)malloc(file_size);
|
char* buf = (char*)malloc(file_size);
|
||||||
if(buf) {
|
if(buf) {
|
||||||
pthread_cleanup_push((void*)&free, (void*)&buf);
|
pthread_cleanup_push((void*)&free, (void*)buf);
|
||||||
if(fread(buf, file_size, 1, fp) == 1) {
|
if(fread(buf, file_size, 1, fp) == 1) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Get dict file size: %u\n", (unsigned int)file_size);
|
printf("Get dict file size: %u\n", (unsigned int)file_size);
|
||||||
@@ -158,7 +158,7 @@ static int send_all(thread_timer_t *timer) {
|
|||||||
//FILE* fp = fopen("raw_after_enc", "wb+");
|
//FILE* fp = fopen("raw_after_enc", "wb+");
|
||||||
//fwrite(encbuf, file_size, 1, fp);
|
//fwrite(encbuf, file_size, 1, fp);
|
||||||
//fclose(fp);
|
//fclose(fp);
|
||||||
pthread_cleanup_push((void*)&free, (void*)&encbuf);
|
pthread_cleanup_push((void*)&free, (void*)encbuf);
|
||||||
if(send(timer->accept_fd, timer->dat, strlen(timer->dat), 0) > 0) {
|
if(send(timer->accept_fd, timer->dat, strlen(timer->dat), 0) > 0) {
|
||||||
re = send(timer->accept_fd, encbuf, file_size, 0);
|
re = send(timer->accept_fd, encbuf, file_size, 0);
|
||||||
printf("Send %u bytes.\n", re);
|
printf("Send %u bytes.\n", re);
|
||||||
|
|||||||
Reference in New Issue
Block a user