[compiler-rt] r270181 - [profile] Remove anther malloc use
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 21:52:32 PDT 2016
Author: davidxl
Date: Thu May 19 23:52:27 2016
New Revision: 270181
URL: http://llvm.org/viewvc/llvm-project?rev=270181&view=rev
Log:
[profile] Remove anther malloc use
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=270181&r1=270180&r2=270181&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Thu May 19 23:52:27 2016
@@ -14,6 +14,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef _MSC_VER
+/* For _alloca */
+#endif
+#include <malloc.h>
+
#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
@@ -83,10 +88,9 @@ static void truncateCurrentFile(void) {
/* Create the directory holding the file, if needed. */
if (strchr(Filename, '/') || strchr(Filename, '\\')) {
- char *Copy = malloc(strlen(Filename) + 1);
+ char *Copy = (char *)COMPILER_RT_ALLOCA(strlen(Filename) + 1);
strcpy(Copy, Filename);
__llvm_profile_recursive_mkdir(Copy);
- free(Copy);
}
/* Truncate the file. Later we'll reopen and append. */
More information about the llvm-commits
mailing list