diff options
author | Bruce Momjian <bruce@momjian.us> | 1997-08-18 02:15:04 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1997-08-18 02:15:04 +0000 |
commit | 022903f22e54cbc78b4acc1ef54f73d19a051630 (patch) | |
tree | 2a2d88e2f97a71233a4b61c1ebf549e663f3d3aa /src/backend/utils | |
parent | eaae21fb4d4b8423dbd26731d9fcd3b3cecf2724 (diff) | |
download | postgresql-022903f22e54cbc78b4acc1ef54f73d19a051630.tar.gz postgresql-022903f22e54cbc78b4acc1ef54f73d19a051630.zip |
Reduce open() calls. Replace fopen() calls with calls to fd.c functions.
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 7 | ||||
-rw-r--r-- | src/backend/utils/sort/psort.c | 22 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 71acc8e998a..98849b22c91 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.13 1997/08/12 22:54:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.14 1997/08/18 02:14:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #include "utils/syscache.h" #include "utils/memutils.h" -#include "storage/fd.h" /* for SEEK_ */ +#include "storage/fd.h" #include "fmgr.h" #include "utils/array.h" @@ -463,11 +463,12 @@ _ReadLOArray(char *str, if ( accessfile ) { FILE *afd; - if ((afd = fopen (accessfile, "r")) == NULL) + if ((afd = AllocateFile(accessfile, "r")) == NULL) elog(WARN, "unable to open access pattern file"); *chunkFlag = true; retStr = _ChunkArray(*fd, afd, ndim, dim, baseSize, nbytes, chunkfile); + FreeFile(afd); } return(retStr); } diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index f49e98973de..a5f43deece2 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.15 1997/08/14 16:11:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.16 1997/08/18 02:14:56 momjian Exp $ * * NOTES * Sorts the first relation into the second relation. @@ -763,16 +763,10 @@ gettape() memmove(tp->tl_name, uniqueName, strlen(uniqueName)); - AllocateFile(); - file = fopen(tp->tl_name, "w+"); - if (file == NULL) { - elog(NOTICE, "psort: gettape: fopen returned error code %i", errno); - /* XXX this should not happen */ - FreeFile(); - FREE(tp->tl_name); - FREE(tp); - return(NULL); - } + file = AllocateFile(tp->tl_name, "w+"); + if (file == NULL) + elog(WARN,"Open: %s in %s line %d, %s", tp->tl_name, + __FILE__, __LINE__, strerror(errno)); tp->tl_fd = fileno(file); tp->tl_next = Tapes; @@ -823,8 +817,7 @@ destroytape(FILE *file) if ((fd = fileno(file)) == tp->tl_fd) { Tapes = tp->tl_next; - fclose(file); - FreeFile(); + FreeFile(file); unlink(tp->tl_name); FREE(tp->tl_name); FREE(tp); @@ -833,8 +826,7 @@ destroytape(FILE *file) if (tp->tl_next == NULL) elog(FATAL, "destroytape: tape not found"); if (tp->tl_next->tl_fd == fd) { - fclose(file); - FreeFile(); + FreeFile(file); tq = tp->tl_next; tp->tl_next = tq->tl_next; unlink(tq->tl_name); |