Skip to content

Commit c49d6b6

Browse files
committed
Update pathname.c
1 parent 46488e1 commit c49d6b6

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

src/libltfs/pathname.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include <ICU/unicode/ustring.h>
5858
#include <ICU/unicode/utypes.h>
5959
#include <ICU/unicode/ucnv.h>
60-
#ifdef USE_UNORM2
60+
#ifdef ICU6x
6161
#include <ICU/unicode/unorm2.h>
6262
#else
6363
#include <ICU/unicode/unorm.h>
@@ -67,7 +67,7 @@
6767
#include <unicode/ustring.h>
6868
#include <unicode/utypes.h>
6969
#include <unicode/ucnv.h>
70-
#ifdef USE_UNORM2
70+
#ifdef ICU6x
7171
#include <unicode/unorm2.h>
7272
#else
7373
#include <unicode/unorm.h>
@@ -96,21 +96,6 @@ int _pathname_utf8_to_system_icu(const char *src, char **dest);
9696
int _pathname_normalize_utf8_nfd_icu(const char *src, char **dest);
9797

9898

99-
/*
100-
* On Visual Studio, free() gets stuck when you use it with an allocated pointer like all these methods above.
101-
* This method it is to reallocate the memory and then free it, it was easier than try to clean up this horrible code.
102-
* Seriously, what was the purpose of having a pointer of pointers if you use it all the time like a single pointer? - GPV -
103-
* @param ptr, a useless allocated pointer.
104-
*/
105-
static void freeUselessAllocatedPointer(UChar** ptr)
106-
{
107-
if (*ptr == NULL) return;
108-
*ptr = realloc(*ptr, 1);
109-
free(*ptr);
110-
*ptr = NULL;
111-
}
112-
113-
11499
/**
115100
* Convert a path name in the system locale to the canonical LTFS form (UTF-8, NFC).
116101
* @param name file, directory, or xattr name to format
@@ -491,13 +476,13 @@ int _pathname_format_icu(const char *src, char **dest, bool validate, bool allow
491476
/* normalize */
492477
ret = _pathname_normalize_nfc_icu(utf16_name, &utf16_name_norm);
493478
if (utf16_name != utf16_name_norm)
494-
freeUselessAllocatedPointer(&utf16_name);
479+
free(utf16_name);
495480
if (ret < 0)
496481
return ret;
497482

498483
/* convert to UTF-8 */
499484
ret = _pathname_utf16_to_utf8_icu(utf16_name_norm, dest);
500-
freeUselessAllocatedPointer(&utf16_name_norm);
485+
free(utf16_name_norm);
501486
if (ret < 0)
502487
return ret;
503488

0 commit comments

Comments
 (0)