refs #5127 allocate space for getcwd ourselves, to avoid system malloc conflicts with jemalloc frees that showed up on osx

git-svn-id: file:///svn/toku/tokudb@50913 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
Leif Walsh 2013-04-17 00:01:22 -04:00 committed by Yoni Fogel
parent 526c4e7299
commit 491c2460d5
2 changed files with 8 additions and 5 deletions

View file

@ -6,6 +6,8 @@
#include "log-internal.h"
#include "logcursor.h"
#include <limits.h>
#include <unistd.h>
enum lc_direction { LC_FORWARD, LC_BACKWARD, LC_FIRST, LC_LAST };
@ -133,11 +135,11 @@ static int lc_create(TOKULOGCURSOR *lc, const char *log_dir) {
cursor->logdir = (char *) toku_xmalloc(strlen(log_dir)+1);
sprintf(cursor->logdir, "%s", log_dir);
} else {
char *cwd = getcwd(NULL, 0);
char cwdbuf[PATH_MAX];
char *cwd = getcwd(cwdbuf, PATH_MAX);
assert(cwd);
cursor->logdir = (char *) toku_xmalloc(strlen(cwd)+strlen(log_dir)+2);
sprintf(cursor->logdir, "%s/%s", cwd, log_dir);
toku_free(cwd);
}
cursor->logfiles = NULL;
cursor->n_logfiles = 0;

View file

@ -6,6 +6,8 @@
#include <memory.h>
#include <ctype.h>
#include <limits.h>
#include <unistd.h>
#include "ft.h"
#include "log-internal.h"
@ -116,16 +118,15 @@ static int open_logdir(TOKULOGGER logger, const char *directory) {
if (toku_os_is_absolute_name(directory)) {
logger->directory = toku_strdup(directory);
} else {
char *cwd = getcwd(NULL, 0);
char cwdbuf[PATH_MAX];
char *cwd = getcwd(cwdbuf, PATH_MAX);
if (cwd == NULL)
return -1;
char *MALLOC_N(strlen(cwd) + strlen(directory) + 2, new_log_dir);
if (new_log_dir == NULL) {
toku_free(cwd);
return -2;
}
sprintf(new_log_dir, "%s/%s", cwd, directory);
toku_free(cwd);
logger->directory = new_log_dir;
}
if (logger->directory==0) return get_error_errno();