mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-05 02:00:25 +08:00
reduce mem use
This commit is contained in:
4
dict.c
4
dict.c
@@ -90,6 +90,10 @@ FILE* get_dict_fp(uint32_t index) {
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
FILE* get_unique_dict_fp() {
|
||||
return fp5;
|
||||
}
|
||||
|
||||
void close_dict(uint8_t lock_type, uint32_t index) {
|
||||
puts("Close dict");
|
||||
lock &= ~lock_type;
|
||||
|
||||
1
dict.h
1
dict.h
@@ -21,6 +21,7 @@ void close_dict(uint8_t lock_type, uint32_t index);
|
||||
int fill_md5();
|
||||
FILE* get_dict_fp(uint32_t index);
|
||||
off_t get_dict_size();
|
||||
FILE* get_unique_dict_fp();
|
||||
int is_md5_equal(uint8_t* digest);
|
||||
FILE *open_dict(uint8_t lock_type, uint32_t index);
|
||||
|
||||
|
||||
2
server.c
2
server.c
@@ -550,6 +550,7 @@ static void accept_client() {
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, 1);
|
||||
init_crypto();
|
||||
init_dict_pool(get_unique_dict_fp());
|
||||
if(pid < 0) puts("Error when forking a subprocess.");
|
||||
else while(1) {
|
||||
puts("Ready for accept, waitting...");
|
||||
@@ -612,7 +613,6 @@ int main(int argc, char *argv[]) {
|
||||
fp = fopen(argv[as_daemon?4:3], "rb+");
|
||||
if(!fp) fp = fopen(argv[as_daemon?4:3], "wb+");
|
||||
if(fp) {
|
||||
init_dict_pool(fp);
|
||||
fclose(fp);
|
||||
if(init_dict(argv[as_daemon?4:3])) {
|
||||
fp = NULL;
|
||||
|
||||
Reference in New Issue
Block a user