diff options
author | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2001-01-26 09:05:55 +0000 |
---|---|---|
committer | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2001-01-26 09:05:55 +0000 |
commit | c9e6bb83dadab222f782fb4e9e11a5e78c414e07 (patch) | |
tree | f621d7446b34b4f1e40911e0ad17a8fe31133ddc /file_io/os2/open.c | |
parent | 0b7e804a9fd34bd85422ddba122440887900b842 (diff) | |
download | libapr-c9e6bb83dadab222f782fb4e9e11a5e78c414e07.tar.gz |
apr_put_os_file() expected the caller to have an existing file or init to
NULL. using an existing file doesn't normally work: where would you get a
blank file to shove an FD into? expecting the user to assign to NULL is
error-prone (mod_isapi didn't).
*) always create and return a new file from apr_put_os_file()
*) reimplement apr_open_stderr() in terms of apr_put_os_file()
[ except for win32... some issues there ]
*) remove some (obsolete) inits to NULL
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61131 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/os2/open.c')
-rw-r--r-- | file_io/os2/open.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/file_io/os2/open.c b/file_io/os2/open.c index 8e07c6cd6..e2cfeba1d 100644 --- a/file_io/os2/open.c +++ b/file_io/os2/open.c @@ -220,10 +220,9 @@ apr_status_t apr_get_os_file(apr_os_file_t *thefile, apr_file_t *file) apr_status_t apr_put_os_file(apr_file_t **file, apr_os_file_t *thefile, apr_pool_t *cont) { apr_os_file_t *dafile = thefile; - if ((*file) == NULL) { - (*file) = (apr_file_t *)apr_palloc(cont, sizeof(apr_file_t)); - (*file)->cntxt = cont; - } + + (*file) = apr_palloc(cont, sizeof(apr_file_t)); + (*file)->cntxt = cont; (*file)->filedes = *dafile; (*file)->isopen = TRUE; (*file)->buffered = FALSE; @@ -247,20 +246,9 @@ apr_status_t apr_eof(apr_file_t *fptr) apr_status_t apr_open_stderr(apr_file_t **thefile, apr_pool_t *cont) { - (*thefile) = apr_palloc(cont, sizeof(apr_file_t)); - if ((*thefile) == NULL) { - return APR_ENOMEM; - } - (*thefile)->cntxt = cont; - (*thefile)->filedes = 2; - (*thefile)->fname = NULL; - (*thefile)->isopen = TRUE; - (*thefile)->buffered = FALSE; - (*thefile)->eof_hit = FALSE; - (*thefile)->flags = 0; - (*thefile)->pipe = FALSE; + int fd = 2; - return APR_SUCCESS; + return apr_put_os_file(thefile, &fd, cont); } APR_POOL_IMPLEMENT_ACCESSOR_X(file, cntxt); |