Skip to content

Commit c4f9a1f

Browse files
committed
Feature(runtime): Use sprintf
1 parent 093ebe2 commit c4f9a1f

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

runtime/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ project(hlvm-runtime)
44

55
set(CMAKE_BUILD_TYPE Release)
66
set(CMAKE_CXX_STANDARD 14)
7-
set(SOURCE_FILES helpers.cpp)
8-
9-
#add_executable(runtime main.cpp)
7+
set(SOURCE_FILES helpers.cpp helpers.h helpers.h)
108

119
add_library(hlvm-runtime STATIC ${SOURCE_FILES})

runtime/helpers.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
#include <sstream>
33
#include <iostream>
44

5+
#include "helpers.h"
6+
57
__attribute__ ((visibility ("default"))) const char* number2string(double number) {
6-
std::stringstream s;
8+
char* result = new char[100];
79

8-
s << number;
10+
sprintf(result, "%f", number);
911

10-
return s.str().c_str();
12+
return result;
1113
}

runtime/helpers.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
#ifndef HLVM_RUNTIME_HELPERS_H
3+
#define HLVM_RUNTIME_HELPERS_H
4+
5+
__attribute__ ((visibility ("default"))) const char* number2string(double number);
6+
7+
#endif //HLVM_RUNTIME_HELPERS_H

0 commit comments

Comments
 (0)