more free_nhfile() will already call init_nhfile()

This commit is contained in:
nhmall
2025-05-31 07:36:44 -04:00
parent c05766e99f
commit 31369c2101

View File

@@ -80,12 +80,17 @@ static int length_without_val(const char *user_string, int len);
static void usage(int argc, char **argv);
static const char *briefname(const char *fnam);
void init_nhfile(NHFILE *);
NHFILE *new_nhfile(void);
void free_nhfile(NHFILE *);
void my_close_nhfile(NHFILE *);
extern void init_nhfile(NHFILE *); /* files.c */
extern NHFILE *new_nhfile(void); /* files.c */
extern void free_nhfile(NHFILE *); /* files.c */
/*
* This is a replacement tempered down version of same-named
* function in files.c within #ifndef SFCTOOL blocks.
*/
int delete_savefile(void);
int nhclose(int fd);
// int nhclose(int fd);
int util_strncmpi(const char *s1, const char *s2, size_t sz);
#ifdef UNIX
@@ -462,7 +467,6 @@ open_srcfile(const char *fnam, enum saveformats mystyle)
if (nhfp && nhfp->structlevel) {
fd = open(fq_name, O_RDONLY | O_BINARY, 0);
if (fd < 0) {
init_nhfile(nhfp);
free_nhfile(nhfp);
fprintf(stderr,
"\nsfctool error - unable to open historical-style "
@@ -482,7 +486,6 @@ open_srcfile(const char *fnam, enum saveformats mystyle)
nhfp->fpdef = fopen(fnam, RDBMODE);
if (!nhfp->fpdef) {
init_nhfile(nhfp);
free_nhfile(nhfp);
fprintf(stderr,
"\nsfctool error - unable to open fieldlevel-style "
@@ -577,7 +580,6 @@ create_dstfile(char *fnam, enum saveformats mystyle)
fd = creat(dstfnam, FCMASK);
#endif
if (fd < 0) {
init_nhfile(nhfp);
free_nhfile(nhfp);
fprintf(
stderr,
@@ -594,7 +596,6 @@ create_dstfile(char *fnam, enum saveformats mystyle)
fq_name = fqname(dstfnam, SAVEPREFIX, 0);
nhfp->fpdef = fopen(fq_name, WRBMODE);
if (!nhfp->fpdef) {
init_nhfile(nhfp);
free_nhfile(nhfp);
fprintf(
stderr,