diff options
author | marko@hundin.mysql.fi <> | 2004-02-19 14:56:19 +0200 |
---|---|---|
committer | marko@hundin.mysql.fi <> | 2004-02-19 14:56:19 +0200 |
commit | 7acccd81dc23a89e9221d265e0bcaf3a544ea09b (patch) | |
tree | f56b77fe1045c63a85eb94692ecb9c0cb133c277 /innobase | |
parent | ec06c782396b584b0cc29e43c2ba41a6a9146179 (diff) | |
download | mariadb-git-7acccd81dc23a89e9221d265e0bcaf3a544ea09b.tar.gz |
srv_add_path_separator_if_needed: be static; use memcpy, not sprintf
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/include/srv0start.h | 10 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 25 |
2 files changed, 10 insertions, 25 deletions
diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h index 8d2c3fa12c5..c4c8dac5d7a 100644 --- a/innobase/include/srv0start.h +++ b/innobase/include/srv0start.h @@ -20,16 +20,6 @@ srv_normalize_path_for_win( /*=======================*/ char* str); /* in/out: null-terminated character string */ /************************************************************************* -Adds a slash or a backslash to the end of a string if it is missing -and the string is not empty. */ - -char* -srv_add_path_separator_if_needed( -/*=============================*/ - /* out, own: string which has the separator if the - string is not empty */ - char* str); /* in: null-terminated character string */ -/************************************************************************* Reads the data files and their sizes from a character string given in the .cnf file. */ diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 8ff2076d5d1..b7606685607 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -441,9 +441,9 @@ io_handler_thread( } #ifdef __WIN__ -#define SRV_PATH_SEPARATOR "\\" +#define SRV_PATH_SEPARATOR '\\' #else -#define SRV_PATH_SEPARATOR "/" +#define SRV_PATH_SEPARATOR '/' #endif /************************************************************************* @@ -470,31 +470,26 @@ srv_normalize_path_for_win( Adds a slash or a backslash to the end of a string if it is missing and the string is not empty. */ +static char* srv_add_path_separator_if_needed( /*=============================*/ - /* out, own: string which has the separator if the + /* out: string which has the separator if the string is not empty */ char* str) /* in: null-terminated character string */ { char* out_str; + ulint len = ut_strlen(str); - if (ut_strlen(str) == 0) { + if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) { return(str); } - if (str[ut_strlen(str) - 1] == SRV_PATH_SEPARATOR[0]) { - out_str = ut_malloc(ut_strlen(str) + 1); - - sprintf(out_str, "%s", str); - - return(out_str); - } - - out_str = ut_malloc(ut_strlen(str) + 2); - - sprintf(out_str, "%s%s", str, SRV_PATH_SEPARATOR); + out_str = ut_malloc(len + 2); + memcpy(out_str, str, len); + out_str[len] = SRV_PATH_SEPARATOR; + out_str[len + 1] = 0; return(out_str); } |