aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-02-18 13:23:10 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-02-18 13:23:10 +0000
commit4d2c9c4794908547f833e99f4704593950ba727b (patch)
tree5be2293ec0cf1177ec68b4dd07a50b456df35fe3
parent9374577aed19eafbe2406f40a9a1fd3e9360c1c9 (diff)
use z_close() when appropriate
svn path=/trunk/externals/zexy/; revision=17428
-rw-r--r--src/freadln.c2
-rw-r--r--src/msgfile.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/src/freadln.c b/src/freadln.c
index c78a0bd..e8e09bb 100644
--- a/src/freadln.c
+++ b/src/freadln.c
@@ -106,7 +106,7 @@ static void freadln_open (t_freadln *x, t_symbol *s, t_symbol*type)
pd_error(x, "%s: failed to open %s", s->s_name, filenamebuf);
return;
}
- close(fd);
+ z_close(fd);
len=strlen(filenamebuf);
if (!(x->x_filename=(char*)getbytes(sizeof(char)*(len+strlen(s->s_name)+2)))) {
pd_error(x, "out of memory");
diff --git a/src/msgfile.c b/src/msgfile.c
index 208c476..ac004c4 100644
--- a/src/msgfile.c
+++ b/src/msgfile.c
@@ -38,6 +38,7 @@
+
/* ****************************************************************************** */
/* msgfile : save and load messages... */
@@ -647,17 +648,21 @@ static void msgfile_read2(t_msgfile *x, t_symbol *filename, t_symbol *format)
rmode |= O_BINARY;
#endif
- if ((fd = open_via_path(dirname,
- filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0) {
-
- if((fd=open(filename->s_name, rmode)) < 0) {
+ fd = open_via_path(dirname,
+ filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0);
+
+ if (fd < 0) {
+ /* open via path failed, fall back */
+ fd=open(filename->s_name, rmode);
+ if(fd < 0) {
pd_error(x, "can't open in %s/%s", dirname, filename->s_name);
return;
} else {
+ close(fd);
sprintf(filnam, "%s", filename->s_name);
}
} else {
- close(fd);
+ z_close(fd);
sprintf(filnam, "%s/%s", buf, bufptr);
}
@@ -673,7 +678,6 @@ static void msgfile_read2(t_msgfile *x, t_symbol *filename, t_symbol *format)
if (!(readbuf = t_getbytes(length))) {
pd_error(x, "msgfile_read: could not reserve %ld bytes to read into", length);
fclose(fil);
- close(fd);
return;
}