* editcmd.c (freestrs): New function to clean temporary strings.

* edit.c (edit_clean): Call freestrs().
This commit is contained in:
Pavel Roskin 2002-08-20 23:18:36 +00:00
parent 37318c2b78
commit 42f28932fc
4 changed files with 25 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2002-08-20 Pavel Roskin <proski@gnu.org>
* editcmd.c (freestrs): New function to clean temporary strings.
* edit.c (edit_clean): Call freestrs().
2002-08-20 David Martin <dmartina@excite.com>
* editmenu.c: Use new create_menu() interface.

View File

@ -593,6 +593,10 @@ int edit_clean (WEdit * edit)
free (edit->dir);
/* we don't want to clear the widget */
memset (&(edit->from_here), 0, (unsigned long)&(edit->to_here) - (unsigned long)&(edit->from_here));
/* Free temporary strings used in catstrs() */
freestrs();
return 1;
}
return 0;

View File

@ -270,6 +270,7 @@ int edit_insert_file_cmd (WEdit * edit);
int edit_insert_file (WEdit * edit, const char *filename);
void edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block);
char *catstrs (const char *first, ...);
void freestrs (void);
void edit_refresh_cmd (WEdit * edit);
void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);

View File

@ -102,6 +102,10 @@ char *itoa (int i)
return ++s;
}
/* Temporary strings */
static char *stacked[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/*
This joins strings end on end and allocates memory for the result.
The result is later automatically free'd and must not be free'd
@ -109,8 +113,6 @@ char *itoa (int i)
*/
char *catstrs (const char *first,...)
{
static char *stacked[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static int i = 0;
va_list ap;
int len;
@ -142,6 +144,17 @@ char *catstrs (const char *first,...)
return stacked[i];
}
/* Free temporary strings */
void freestrs(void)
{
int i;
for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) {
if (stacked[i])
free (stacked[i]);
}
}
void edit_help_cmd (WEdit * edit)
{
interactive_display (NULL, "[Internal File Editor]");