mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-07 00:20:43 +08:00
添加内存锻炼器代码
This commit is contained in:
29
others/C/memory/src/config.c
Normal file
29
others/C/memory/src/config.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "../include/config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// 全局配置实例
|
||||
static Config app_config = {
|
||||
.default_memory_size = 100, // 默认100MB
|
||||
.max_memory_size = 8192, // 最大8GB
|
||||
.fill_mode = 0 // 默认填充0
|
||||
};
|
||||
|
||||
// 初始化配置
|
||||
void init_config() {
|
||||
// TODO: 从文件加载配置
|
||||
}
|
||||
|
||||
// 获取当前配置
|
||||
Config* get_config() {
|
||||
return &app_config;
|
||||
}
|
||||
|
||||
// 保存配置到文件
|
||||
void save_config() {
|
||||
FILE* fp = fopen("config.bin", "wb");
|
||||
if (fp) {
|
||||
fwrite(&app_config, sizeof(Config), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user