gui_list fixed, quit during routign fixed.

master
steffen 12 years ago
parent e018fef72b
commit 867acfafcd

@ -1,4 +1,4 @@
/* $Id: gui_selectfile.c,v 1.3 2014/02/12 21:23:06 steffen Exp $ */ /* $Id: gui_selectfile.c,v 1.4 2014/02/12 23:05:35 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui_selectdir.c * gui_selectdir.c
* *
@ -143,33 +143,33 @@ void gui_sfile_update () {
continue; continue;
} }
d_printf ("dir:%s", fname); d_printf ("dir:%s", fname);
if (S_ISDIR(stbuf.st_mode)) { if (cnt >= wsf_listmax) {
/* need more memory? */ /* save old pointer and counter */
if (cnt >= wsf_listmax) { char **tmp = wsf_list;
/* save old pointer and counter */ int i = wsf_listmax-1;
char **tmp = wsf_list;
int i = wsf_listmax-1; /* allocate new list */
wsf_listmax += 512;
/* allocate new list */ wsf_list = ml_malloc (wsf_listmax * sizeof(void*));
wsf_listmax += 512; memset (wsf_list, 0x0, wsf_listmax * sizeof(void*));
wsf_list = ml_malloc (wsf_listmax * sizeof(void*));
memset (wsf_list, 0x0, wsf_listmax * sizeof(void*)); /* copy list */
if (tmp) {
/* copy list */ for (; i >= 0; i--) wsf_list[i] = tmp[i];
if (tmp) { ml_free (tmp);
for (; i >= 0; i--) wsf_list[i] = tmp[i];
ml_free (tmp);
}
/* setup new list */
GUI_LIST_T (wsf_flist)->data = wsf_list;
} }
/* setup new list */
wsf_list[cnt] = ml_malloc (LEN_FILENAME); GUI_LIST_T (wsf_flist)->data = wsf_list;
strncpy (wsf_list[cnt], direntry->d_name, LEN_FILENAME);
d_printf ("added entry:%-3d '%s'", cnt, direntry->d_name);
cnt++;
} }
wsf_list[cnt] = ml_malloc (LEN_FILENAME);
if (S_ISDIR(stbuf.st_mode)) snprintf (wsf_list[cnt], LEN_FILENAME, "[%s]", direntry->d_name);
else snprintf (wsf_list[cnt], LEN_FILENAME, "%s", direntry->d_name);
d_printf ("added entry:%-3d '%s'", cnt, direntry->d_name);
cnt++;
} }
closedir (dir); closedir (dir);

Loading…
Cancel
Save