Commit 94e9a361 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Refactored without fio_malloc in a few places

(todo: find a way to reproduce caching issues on file I/O and add it to selftest.mo)

--HG--
branch : cache-fixes
parent 5d6063652bff
......@@ -184,7 +184,7 @@ static void cmos16_log(breakpoint_t *bkpt)
void adtg_log_task()
{
adtg_buf_pos_max = 128 * 1024;
adtg_buf = fio_malloc(adtg_buf_pos_max * 4 + 0x100);
adtg_buf = malloc(adtg_buf_pos_max * 4 + 0x100);
if(!adtg_buf)
{
......@@ -253,7 +253,7 @@ void adtg_log_task()
/* free buffer */
void *buf = adtg_buf;
adtg_buf = NULL;
fio_free(buf);
free(buf);
}
static MENU_SELECT_FUNC(adtg_log_toggle)
......
......@@ -189,7 +189,7 @@ int config_save_file(const char *filename)
DebugMsg( DM_MAGIC, 3, "%s: saving to %s", __func__, filename );
#define MAX_SIZE 10240
char* msg = fio_malloc(MAX_SIZE);
char* msg = malloc(MAX_SIZE);
msg[0] = '\0';
snprintf( msg, MAX_SIZE,
......@@ -231,7 +231,7 @@ int config_save_file(const char *filename)
FILE * file = FIO_CreateFile( filename );
if(!file)
{
fio_free(msg);
free(msg);
return -1;
}
......@@ -239,7 +239,7 @@ int config_save_file(const char *filename)
FIO_CloseFile( file );
fio_free(msg);
free(msg);
return count;
}
......@@ -316,7 +316,7 @@ int config_parse_file(const char *filename)
config_file_buf = (void*)read_entire_file(filename, &config_file_size);
config_file_pos = 0;
config_parse();
fio_free(config_file_buf);
free(config_file_buf);
config_file_buf = 0;
return 1;
}
......@@ -467,7 +467,7 @@ unsigned int module_config_load(char *filename, module_entry_t *module)
return -1;
config_file_pos = 0;
module_config_parse(module);
fio_free(config_file_buf);
free(config_file_buf);
config_file_buf = 0;
return 0;
}
......@@ -477,7 +477,7 @@ unsigned int module_config_save(char *filename, module_entry_t *module)
if (!module->config)
return -1;
char* msg = fio_malloc(MAX_SIZE);
char* msg = malloc(MAX_SIZE);
msg[0] = '\0';
snprintf( msg, MAX_SIZE,
......@@ -510,7 +510,7 @@ unsigned int module_config_save(char *filename, module_entry_t *module)
FILE * file = FIO_CreateFile( filename );
if (!file)
{
fio_free(msg);
free(msg);
return -1;
}
......@@ -518,7 +518,7 @@ unsigned int module_config_save(char *filename, module_entry_t *module)
FIO_CloseFile( file );
finish:
fio_free(msg);
free(msg);
return 0;
}
......
......@@ -5477,7 +5477,7 @@ static void menu_set_flags(char* menu_name, char* entry_name, int flags)
static void menu_save_flags(char* filename)
{
char* cfg = fio_malloc(CFG_SIZE);
char* cfg = malloc(CFG_SIZE);
cfg[0] = '\0';
int cfglen = 0;
int lastlen = 0;
......@@ -5513,7 +5513,7 @@ static void menu_save_flags(char* filename)
FIO_CloseFile( file );
end:
fio_free(cfg);
free(cfg);
}
static void menu_load_flags(char* filename)
......@@ -5567,7 +5567,7 @@ void config_menu_save_flags()
/*void menu_save_all_items_dbg()
{
char* cfg = fio_malloc(CFG_SIZE);
char* cfg = malloc(CFG_SIZE);
cfg[0] = '\0';
int unnamed = 0;
......@@ -5594,7 +5594,7 @@ void config_menu_save_flags()
NotifyBox(5000, "Menu items: %d unnamed.", unnamed);
end:
fio_free(cfg);
free(cfg);
}*/
int menu_get_value_from_script(const char* name, const char* entry_name)
......
......@@ -481,11 +481,11 @@ PTP_HANDLER( PTP_OC_CHDK, 0 )
if ( s >= BUF_SIZE )
{
recv_ptp_data(context,buf,BUF_SIZE);
FIO_WriteFile(f, UNCACHEABLE(buf), BUF_SIZE);
FIO_WriteFile(f, buf, BUF_SIZE);
s -= BUF_SIZE;
} else {
recv_ptp_data(context,buf,s);
FIO_WriteFile(f, UNCACHEABLE(buf), s);
FIO_WriteFile(f, buf, s);
s = 0;
}
}
......@@ -550,7 +550,7 @@ PTP_HANDLER( PTP_OC_CHDK, 0 )
}
tmp = s;
t = s;
while ( (r = FIO_ReadFile(f, UNCACHEABLE(buf), (t<BUF_SIZE) ? t : BUF_SIZE)) > 0 )
while ( (r = FIO_ReadFile(f, buf, (t<BUF_SIZE) ? t : BUF_SIZE)) > 0 )
{
t -= r;
// cannot use send_ptp_data here
......
......@@ -45,7 +45,7 @@ int take_screenshot( char* filename, uint32_t mode )
/* setup output buffer */
/* todo: support HDMI resolutions? */
rgb = fio_malloc(720 * 480 * 3);
rgb = malloc(720 * 480 * 3);
if (!rgb) goto err;
/* fill it with data */
......
......@@ -23,22 +23,15 @@ my_fprintf(
va_list ap;
int len = 0;
int maxlen = 1024;
char* buf = fio_malloc(maxlen);
if (!buf)
{
maxlen = 128;
buf = fio_malloc(maxlen);
}
const int maxlen = 512;
char buf[maxlen];
if (buf)
{
va_start( ap, fmt );
len = vsnprintf( buf, maxlen-1, fmt, ap );
va_end( ap );
FIO_WriteFile( file, buf, len );
fio_free(buf);
}
return len;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment