diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-10-28 14:51:13 -0700 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-10-28 19:02:36 -0700 |
| commit | 3286c408eccb18c525ca123383f3ebf5097441bc (patch) | |
| tree | 4422fe16ab4f7b9cf713e0209cbb74fb4115889e /src/win32 | |
| parent | da37654d04617b4dacce6e7a4796007d2854624d (diff) | |
| download | libgit2-3286c408eccb18c525ca123383f3ebf5097441bc.tar.gz | |
global: Properly use `git__` memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
Diffstat (limited to 'src/win32')
| -rw-r--r-- | src/win32/dir.c | 14 | ||||
| -rw-r--r-- | src/win32/posix.h | 2 | ||||
| -rw-r--r-- | src/win32/posix_w32.c | 44 | ||||
| -rw-r--r-- | src/win32/utf-conv.c | 4 |
4 files changed, 32 insertions, 32 deletions
diff --git a/src/win32/dir.c b/src/win32/dir.c index fea74b4eb..01aaaaad3 100644 --- a/src/win32/dir.c +++ b/src/win32/dir.c @@ -39,18 +39,18 @@ git__DIR *git__opendir(const char *dir) new->dir = git__malloc(strlen(dir)+1); if (!new->dir) { - free(new); + git__free(new); return NULL; } strcpy(new->dir, dir); filter_w = gitwin_to_utf16(filter); new->h = FindFirstFileW(filter_w, &new->f); - free(filter_w); + git__free(filter_w); if (new->h == INVALID_HANDLE_VALUE) { - free(new->dir); - free(new); + git__free(new->dir); + git__free(new); return NULL; } new->first = 1; @@ -93,7 +93,7 @@ void git__rewinddir(git__DIR *d) if (init_filter(filter, sizeof(filter), d->dir)) { filter_w = gitwin_to_utf16(filter); d->h = FindFirstFileW(filter_w, &d->f); - free(filter_w); + git__free(filter_w); if (d->h != INVALID_HANDLE_VALUE) d->first = 1; @@ -107,8 +107,8 @@ int git__closedir(git__DIR *d) if (d->h != INVALID_HANDLE_VALUE) FindClose(d->h); if (d->dir) - free(d->dir); - free(d); + git__free(d->dir); + git__free(d); } return 0; } diff --git a/src/win32/posix.h b/src/win32/posix.h index 3774e7883..5dcdb5f85 100644 --- a/src/win32/posix.h +++ b/src/win32/posix.h @@ -26,7 +26,7 @@ GIT_INLINE(int) p_mkdir(const char *path, int GIT_UNUSED(mode)) GIT_UNUSED_ARG(mode) - free(buf); + git__free(buf); return ret; } diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index a05aafcca..ed7450a94 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -20,7 +20,7 @@ int p_unlink(const char *path) buf = gitwin_to_utf16(path); _wchmod(buf, 0666); ret = _wunlink(buf); - free(buf); + git__free(buf); return ret; } @@ -86,11 +86,11 @@ static int do_lstat(const char *file_name, struct stat *buf) buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime)); buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); - free(fbuf); + git__free(fbuf); return GIT_SUCCESS; } - free(fbuf); + git__free(fbuf); switch (GetLastError()) { case ERROR_ACCESS_DENIED: @@ -171,7 +171,7 @@ int p_readlink(const char *link, char *target, size_t target_len) FILE_FLAG_BACKUP_SEMANTICS, // normal file NULL); // no attr. template - free(link_w); + git__free(link_w); if (hFile == INVALID_HANDLE_VALUE) return GIT_EOSERR; @@ -184,17 +184,17 @@ int p_readlink(const char *link, char *target, size_t target_len) dwRet = pGetFinalPath(hFile, target_w, target_len, 0x0); if (dwRet >= target_len) { - free(target_w); + git__free(target_w); CloseHandle(hFile); return GIT_ENOMEM; } if (!WideCharToMultiByte(CP_UTF8, 0, target_w, -1, target, target_len * sizeof(char), NULL, NULL)) { - free(target_w); + git__free(target_w); return GIT_EOSERR; } - free(target_w); + git__free(target_w); CloseHandle(hFile); if (dwRet > 4) { @@ -226,7 +226,7 @@ int p_open(const char *path, int flags) wchar_t* buf = gitwin_to_utf16(path); fd = _wopen(buf, flags | _O_BINARY); - free(buf); + git__free(buf); return fd; } @@ -236,7 +236,7 @@ int p_creat(const char *path, int mode) wchar_t* buf = gitwin_to_utf16(path); fd = _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, mode); - free(buf); + git__free(buf); return fd; } @@ -246,11 +246,11 @@ int p_getcwd(char *buffer_out, size_t size) _wgetcwd(buf, (int)size); if (!WideCharToMultiByte(CP_UTF8, 0, buf, -1, buffer_out, size, NULL, NULL)) { - free(buf); + git__free(buf); return GIT_EOSERR; } - free(buf); + git__free(buf); return GIT_SUCCESS; } @@ -264,7 +264,7 @@ int p_chdir(const char* path) wchar_t* buf = gitwin_to_utf16(path); int ret = _wchdir(buf); - free(buf); + git__free(buf); return ret; } @@ -273,7 +273,7 @@ int p_chmod(const char* path, int mode) wchar_t* buf = gitwin_to_utf16(path); int ret = _wchmod(buf, mode); - free(buf); + git__free(buf); return ret; } @@ -282,7 +282,7 @@ int p_rmdir(const char* path) wchar_t* buf = gitwin_to_utf16(path); int ret = _wrmdir(buf); - free(buf); + git__free(buf); return ret; } @@ -294,7 +294,7 @@ int p_hide_directory__w32(const char *path) error = SetFileAttributesW(buf, FILE_ATTRIBUTE_HIDDEN) != 0 ? GIT_SUCCESS : GIT_ERROR; /* MSDN states a "non zero" value indicates a success */ - free(buf); + git__free(buf); if (error < GIT_SUCCESS) error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path); @@ -314,21 +314,21 @@ char *p_realpath(const char *orig_path, char *buffer) } ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL); - free(orig_path_w); + git__free(orig_path_w); if (!ret || ret > GIT_PATH_MAX) { - free(buffer_w); - if (alloc) free(buffer); + git__free(buffer_w); + if (alloc) git__free(buffer); return NULL; } if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL)) { - free(buffer_w); - if (alloc) free(buffer); + git__free(buffer_w); + if (alloc) git__free(buffer); } - free(buffer_w); + git__free(buffer_w); git_path_mkposix(buffer); return buffer; } @@ -384,7 +384,7 @@ int p_access(const char* path, int mode) int ret; ret = _waccess(buf, mode); - free(buf); + git__free(buf); return ret; } diff --git a/src/win32/utf-conv.c b/src/win32/utf-conv.c index cb607839e..b41c78f92 100644 --- a/src/win32/utf-conv.c +++ b/src/win32/utf-conv.c @@ -50,7 +50,7 @@ wchar_t* gitwin_to_utf16(const char* str) ret = (wchar_t*)git__malloc(cb); if (MultiByteToWideChar(_active_codepage, 0, str, -1, ret, cb) == 0) { - free(ret); + git__free(ret); ret = NULL; } @@ -79,7 +79,7 @@ char* gitwin_from_utf16(const wchar_t* str) ret = (char*)git__malloc(cb); if (WideCharToMultiByte(_active_codepage, 0, str, -1, ret, cb, NULL, NULL) == 0) { - free(ret); + git__free(ret); ret = NULL; } |
