Commit 5f882564 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5127 allocate space for getcwd ourselves, to avoid system malloc...

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
parent 068ac9f8
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "log-internal.h" #include "log-internal.h"
#include "logcursor.h" #include "logcursor.h"
#include <limits.h>
#include <unistd.h>
enum lc_direction { LC_FORWARD, LC_BACKWARD, LC_FIRST, LC_LAST }; 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) { ...@@ -133,11 +135,11 @@ static int lc_create(TOKULOGCURSOR *lc, const char *log_dir) {
cursor->logdir = (char *) toku_xmalloc(strlen(log_dir)+1); cursor->logdir = (char *) toku_xmalloc(strlen(log_dir)+1);
sprintf(cursor->logdir, "%s", log_dir); sprintf(cursor->logdir, "%s", log_dir);
} else { } else {
char *cwd = getcwd(NULL, 0); char cwdbuf[PATH_MAX];
char *cwd = getcwd(cwdbuf, PATH_MAX);
assert(cwd); assert(cwd);
cursor->logdir = (char *) toku_xmalloc(strlen(cwd)+strlen(log_dir)+2); cursor->logdir = (char *) toku_xmalloc(strlen(cwd)+strlen(log_dir)+2);
sprintf(cursor->logdir, "%s/%s", cwd, log_dir); sprintf(cursor->logdir, "%s/%s", cwd, log_dir);
toku_free(cwd);
} }
cursor->logfiles = NULL; cursor->logfiles = NULL;
cursor->n_logfiles = 0; cursor->n_logfiles = 0;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <memory.h> #include <memory.h>
#include <ctype.h> #include <ctype.h>
#include <limits.h>
#include <unistd.h>
#include "ft.h" #include "ft.h"
#include "log-internal.h" #include "log-internal.h"
...@@ -116,16 +118,15 @@ static int open_logdir(TOKULOGGER logger, const char *directory) { ...@@ -116,16 +118,15 @@ static int open_logdir(TOKULOGGER logger, const char *directory) {
if (toku_os_is_absolute_name(directory)) { if (toku_os_is_absolute_name(directory)) {
logger->directory = toku_strdup(directory); logger->directory = toku_strdup(directory);
} else { } else {
char *cwd = getcwd(NULL, 0); char cwdbuf[PATH_MAX];
char *cwd = getcwd(cwdbuf, PATH_MAX);
if (cwd == NULL) if (cwd == NULL)
return -1; return -1;
char *MALLOC_N(strlen(cwd) + strlen(directory) + 2, new_log_dir); char *MALLOC_N(strlen(cwd) + strlen(directory) + 2, new_log_dir);
if (new_log_dir == NULL) { if (new_log_dir == NULL) {
toku_free(cwd);
return -2; return -2;
} }
sprintf(new_log_dir, "%s/%s", cwd, directory); sprintf(new_log_dir, "%s/%s", cwd, directory);
toku_free(cwd);
logger->directory = new_log_dir; logger->directory = new_log_dir;
} }
if (logger->directory==0) return get_error_errno(); if (logger->directory==0) return get_error_errno();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment