summaryrefslogtreecommitdiff
path: root/file_io/os2
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2019-06-25 14:21:56 +0000
committerJoe Orton <jorton@apache.org>2019-06-25 14:21:56 +0000
commit864ce9d1b1784c31386a7a5ff568e78f56a0a75f (patch)
tree75ac7cea477231ea31a07f15b37a47a6cd5e010b /file_io/os2
parente0f71494adc916c15fca5038ac1e45b77113168c (diff)
downloadapr-864ce9d1b1784c31386a7a5ff568e78f56a0a75f.tar.gz
Add apr_dir_pread(), a variant of apr_dir_read() which allows callers
to read a directory with constant memory consumption: * include/apr_file_info.h: Add warning on memory consumption for apr_dir_read; declare apr_dir_pread. * file_io/unix/dir.c (apr_dir_pread): Rename from apr_dir_read and take pool argument. (apr_dir_read): Reimplement using it. * file_io/win32/dir.c, file_io/os2/dir.c: Likewise, but untested. * test/testdir.c (test_pread) [APR_POOL_DEBUG]: Add test case. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1862071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/os2')
-rw-r--r--file_io/os2/dir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/file_io/os2/dir.c b/file_io/os2/dir.c
index f1554b6f3..d1a0072cc 100644
--- a/file_io/os2/dir.c
+++ b/file_io/os2/dir.c
@@ -79,24 +79,28 @@ APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir)
return APR_FROM_OS_ERROR(rv);
}
-
-
APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
apr_dir_t *thedir)
{
+ return apr_dir_pread(finfo, wanted, thedir, thedir->pool);
+}
+
+APR_DECLARE(apr_status_t) apr_dir_pread(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_dir_t *thedir, apr_pool_t *pool)
+{
int rv;
ULONG entries = 1;
if (thedir->handle == 0) {
thedir->handle = HDIR_CREATE;
- rv = DosFindFirst(apr_pstrcat(thedir->pool, thedir->dirname, "/*", NULL), &thedir->handle,
+ rv = DosFindFirst(apr_pstrcat(pool, thedir->dirname, "/*", NULL), &thedir->handle,
FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY,
&thedir->entry, sizeof(thedir->entry), &entries, FIL_STANDARD);
} else {
rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry), &entries);
}
- finfo->pool = thedir->pool;
+ finfo->pool = pool;
finfo->fname = NULL;
finfo->valid = 0;