📄 utils.c
字号:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <errno.h>//////////////////////////////////////////////////////////////////////// Utils functions//////////////////////////////////////////////////////////////////////char *safe_malloc(int size){ char *p = NULL; int retry = 5; while (retry > 0 && ((p = malloc(size)) == NULL)) { fprintf(stderr, "malloc() failed: %s\n", strerror(errno)); sleep(1); retry--; } return p;}void safe_free(void *p){ if (p) { fprintf(stdout, "DEBUG: try to free %p\n", p); free(p); p = NULL; } p = NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -