Fix for Windows where deprecated realization itoa exists

This commit is contained in:
Elena Lepilkina
2019-02-19 14:24:31 +03:00
parent bf7040a119
commit a18395b9d7
2 changed files with 3 additions and 10 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.structsBenchmarks
import kotlinx.cinterop.*
import platform.posix.*
import kotlin.math.sqrt
const val benchmarkSize = 10000
@@ -38,7 +39,7 @@ actual fun structBenchmark() {
val element = alloc<ElementS>()
element.floatValue = i + sqrt(i.toDouble()).toFloat()
element.integer = i.toLong()
itoa(i, element.string, 10)
sprintf(element.string, "%d", i)
element.contains = containsFunction
elementsList.add(element)
@@ -75,14 +75,6 @@ struct ElementS multiplyElementS(struct ElementS element, int coefficient) {
return newElement;
}
void itoa(int val, char* buffer, int base){
int i = 30;
for(; val && i ; --i, val /= base)
buffer[i] = "0123456789abcdef"[val % base];
buffer[31] = '\0';
}
union ElementU* sumElementUPtr(const union ElementU* first, const union ElementU* second) {
if (first == NULL || second == NULL) {
return NULL;
@@ -99,7 +91,7 @@ struct ElementS* sumElementSPtr(const struct ElementS* first, const struct Eleme
struct ElementS* newElement = (struct ElementS*)malloc(sizeof(struct ElementS));
newElement->integer = first->integer + second->integer;
newElement->floatValue = first->floatValue + second->floatValue;
itoa(newElement->integer, newElement->string, 10);
sprintf(newElement->string, "%d", newElement->integer);
return newElement;
}