nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: intro `Float.lerp` for simple linear interpolation
[nit.git]
/
c_src
/
string_nit.c
diff --git
a/c_src/string_nit.c
b/c_src/string_nit.c
index
0159249
..
686d6be
100644
(file)
--- a/
c_src/string_nit.c
+++ b/
c_src/string_nit.c
@@
-11,10
+11,12
@@
#include "string_nit.h"
#include "string_nit.h"
+// Returns the length of `recv` as a `char*` (excluding the null character)
+long native_int_length_str(long recv){
+ return snprintf(NULL, 0, "%ld", recv);
+}
+
// Integer to NativeString method
// Integer to NativeString method
-char* native_int_to_s(long recv){
- int len = snprintf(NULL, 0, "%ld", recv);
- char* str = malloc(len);
- sprintf(str, "%ld", recv);
- return str;
+void native_int_to_s(long recv, char* str, long buflen){
+ snprintf(str, buflen, "%ld", recv);
}
}