Once again improve existing filename handling

Several potential problems.
- we could end up dereferencing exiting_filename when it was NULL
- we could free the default_filename by mistake -
  subsurface_default_filename always needs to return a copy of it
- closing the existing file before opening a new one repopulated the
  existing_filename with the default filename - preventing the opened
  file to become the new existing filename

Also, make existing filename a const char * and make file_open have the
same sensible default folder behavior as the other file related functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-09-15 20:51:06 -07:00
parent fa2f1b6eb0
commit 7148dea827
5 changed files with 23 additions and 12 deletions

2
dive.h
View file

@ -463,7 +463,7 @@ const char *monthname(int mon);
extern const char *star_strings[];
extern const char *default_filename;
extern char *existing_filename;
extern const char *existing_filename;
extern const char *subsurface_default_filename(void);
#define AIR_PERMILLE 209