From 11d51ca63184b760e2537bbe08c5ca4c63bd4854 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 26 Oct 2011 16:43:55 -0700 Subject: windows: Add support for non-UTF codepages Our previous assumption that all paths in Windows are encoded in UTF-8 is rather weak, specially when considering that Git is encoding-agnostic. These set of functions allow the user to change the library's active codepage globally, so it is possible to access paths and files on all international versions of Windows. Note that the default encoding here is UTF-8 because we assume that 99% of all Git repositories will be in UTF-8. Also, if you use non-ascii characters in paths, anywhere, please burn on a fire. --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index f53afa145..ad6f88575 100644 --- a/src/config.c +++ b/src/config.c @@ -370,7 +370,7 @@ static int win32_find_system(char *system_config_path) return GIT_ENOTFOUND; } - apphome_utf8 = conv_utf16_to_utf8(apphome_utf16); + apphome_utf8 = gitwin_from_utf16(apphome_utf16); free(apphome_utf16); if (strlen(apphome_utf8) >= GIT_PATH_MAX) { -- cgit v1.2.1 From 3286c408eccb18c525ca123383f3ebf5097441bc Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 28 Oct 2011 14:51:13 -0700 Subject: global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers. --- src/config.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index ad6f88575..4e48ff7f4 100644 --- a/src/config.c +++ b/src/config.c @@ -35,11 +35,11 @@ void git_config_free(git_config *cfg) internal = git_vector_get(&cfg->files, i); file = internal->file; file->free(file); - free(internal); + git__free(internal); } git_vector_free(&cfg->files); - free(cfg); + git__free(cfg); } static int config_backend_cmp(const void *a, const void *b) @@ -61,7 +61,7 @@ int git_config_new(git_config **out) memset(cfg, 0x0, sizeof(git_config)); if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) { - free(cfg); + git__free(cfg); return GIT_ENOMEM; } @@ -125,7 +125,7 @@ int git_config_add_file(git_config *cfg, git_config_file *file, int priority) internal->priority = priority; if (git_vector_insert(&cfg->files, internal) < 0) { - free(internal); + git__free(internal); return GIT_ENOMEM; } @@ -366,20 +366,20 @@ static int win32_find_system(char *system_config_path) return git__throw(GIT_ERROR, "Failed to expand environment strings"); if (_waccess(apphome_utf16, F_OK) < 0) { - free(apphome_utf16); + git__free(apphome_utf16); return GIT_ENOTFOUND; } apphome_utf8 = gitwin_from_utf16(apphome_utf16); - free(apphome_utf16); + git__free(apphome_utf16); if (strlen(apphome_utf8) >= GIT_PATH_MAX) { - free(apphome_utf8); + git__free(apphome_utf8); return git__throw(GIT_ESHORTBUFFER, "Path is too long"); } strcpy(system_config_path, apphome_utf8); - free(apphome_utf8); + git__free(apphome_utf8); return GIT_SUCCESS; } #endif -- cgit v1.2.1