diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-20 12:33:04 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-20 12:33:04 +0400 |
commit | ba6b83d63dbd0c22b2a1a46d273d5bd51d039997 (patch) | |
tree | 0ff594608a26bf35a4ca6052fa172d0535680104 /source/blender/blenlib/intern/storage.c | |
parent | 347ba7f159b4c01c3c7ecaeb2005b411d348eb47 (diff) |
Get rid of PATH_MAX in Ghost System X11
The reason of this is because PATH_MAX is not guaranteed
to be defined on all platforms and Hurd doesn't define it.
So either we need to support arbitrary long file path or
we need to define own maximum path length.
The rule here would be:
- If it's not big trouble to support arbitrary long paths
(i.e. in ghost by using std::string instead of char*)
then arbitrary long path shall be implemented.
- For other cases to use PATH_MAX please include BLI_fileops.h
which takes care of making sure PATH_MAX is defined.
Additional change: get rid of own changes made yesterday
which were supposed to make storage.c work fine in cases
PATH_MAX is not define, but on the second though it lead
to unneeded complication of the code.
Thanks Campbell for review!
Diffstat (limited to 'source/blender/blenlib/intern/storage.c')
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index c1645c05359..e40527b1bb6 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -70,7 +70,6 @@ #ifdef WIN32 # include <io.h> # include <direct.h> -# include <limits.h> /* PATH_MAX */ # include "BLI_winstuff.h" # include "utfconv.h" #else @@ -255,18 +254,11 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname) struct dirlink * dlink = (struct dirlink *) dirbase.first; struct direntry *file = &dir_ctx->files[dir_ctx->nrfiles]; while (dlink) { -#ifdef PATH_MAX - char static_fullname[PATH_MAX]; - char *fullname = static_fullname; - size_t fullname_size = PATH_MAX; -#else - size_t fullname_size = strlen(dirname) + strlen(dlink->name) + 2; - char *fullname = MEM_mallocN(fullname_size, "bli_builddir fullname"); -#endif + char fullname[PATH_MAX]; memset(file, 0, sizeof(struct direntry)); file->relname = dlink->name; file->path = BLI_strdupcat(dirname, dlink->name); - BLI_join_dirfile(fullname, fullname_size, dirname, dlink->name); + BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name); // use 64 bit file size, only needed for WIN32 and WIN64. // Excluding other than current MSVC compiler until able to test #ifdef WIN32 @@ -288,9 +280,6 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname) dir_ctx->nrfiles++; file++; dlink = dlink->next; -#ifndef PATH_MAX - MEM_freeN(fullname); -#endif } } else { |