"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "file_io/unix/dir.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

dir.c  (apr-1.6.5.tar.bz2):dir.c  (apr-1.7.0.tar.bz2)
skipping to change at line 27 skipping to change at line 27
#include "apr_arch_file_io.h" #include "apr_arch_file_io.h"
#include "apr_strings.h" #include "apr_strings.h"
#include "apr_portable.h" #include "apr_portable.h"
#if APR_HAVE_SYS_SYSLIMITS_H #if APR_HAVE_SYS_SYSLIMITS_H
#include <sys/syslimits.h> #include <sys/syslimits.h>
#endif #endif
#if APR_HAVE_LIMITS_H #if APR_HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#endif #endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif
static apr_status_t dir_cleanup(void *thedir) static apr_status_t dir_cleanup(void *thedir)
{ {
apr_dir_t *dir = thedir; apr_dir_t *dir = thedir;
if (closedir(dir->dirstruct) == 0) { if (closedir(dir->dirstruct) == 0) {
return APR_SUCCESS; return APR_SUCCESS;
} }
else { else {
return errno; return errno;
} }
} }
skipping to change at line 74 skipping to change at line 78
if (path[i] == PATH_SEPARATOR) if (path[i] == PATH_SEPARATOR)
break; break;
} }
return apr_pstrndup (pool, path, (i < 0) ? 0 : i); return apr_pstrndup (pool, path, (i < 0) ? 0 : i);
} }
apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname,
apr_pool_t *pool) apr_pool_t *pool)
{ {
/* On some platforms (e.g., Linux+GNU libc), d_name[] in struct
* dirent is declared with enough storage for the name. On other
* platforms (e.g., Solaris 8 for Intel), d_name is declared as a
* one-byte array. Note: gcc evaluates this at compile time.
*/
apr_size_t dirent_size =
sizeof(*(*new)->entry) +
(sizeof((*new)->entry->d_name) > 1 ? 0 : 255);
DIR *dir = opendir(dirname); DIR *dir = opendir(dirname);
if (!dir) { if (!dir) {
return errno; return errno;
} }
(*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); (*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t));
(*new)->pool = pool; (*new)->pool = pool;
(*new)->dirname = apr_pstrdup(pool, dirname); (*new)->dirname = apr_pstrdup(pool, dirname);
(*new)->dirstruct = dir; (*new)->dirstruct = dir;
(*new)->entry = apr_pcalloc(pool, dirent_size);
#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
&& !defined(READDIR_IS_THREAD_SAFE)
/* On some platforms (e.g., Linux+GNU libc), d_name[] in struct
* dirent is declared with enough storage for the name. On other
* platforms (e.g., Solaris 8 for Intel), d_name is declared as a
* one-byte array. Note: gcc evaluates this at compile time.
*/
(*new)->entry = apr_pcalloc(pool, sizeof(*(*new)->entry) +
(sizeof((*new)->entry->d_name) > 1
? 0 : NAME_MAX));
#else
(*new)->entry = NULL;
#endif
apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup, apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup,
apr_pool_cleanup_null); apr_pool_cleanup_null);
return APR_SUCCESS; return APR_SUCCESS;
} }
apr_status_t apr_dir_close(apr_dir_t *thedir) apr_status_t apr_dir_close(apr_dir_t *thedir)
{ {
return apr_pool_cleanup_run(thedir->pool, thedir, dir_cleanup); return apr_pool_cleanup_run(thedir->pool, thedir, dir_cleanup);
} }
 End of changes. 3 change blocks. 
9 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)