diff --git a/kotstd/include/BooleanArray.kt b/kotstd/include/BooleanArray.kt index d39a0695fc5..e5c85c56b43 100644 --- a/kotstd/include/BooleanArray.kt +++ b/kotstd/include/BooleanArray.kt @@ -8,6 +8,11 @@ class BooleanArray(var size: Int) { init { this.data = malloc_array(kotlinclib_boolean_size() * this.size) + var index = 0 + while (index < this.size) { + set(index, false) + index = index + 1 + } } /** Returns the array element at the given [index]. This method can be called using the index operator. */ diff --git a/kotstd/include/ByteArray.kt b/kotstd/include/ByteArray.kt index bca1483879e..c746a236677 100644 --- a/kotstd/include/ByteArray.kt +++ b/kotstd/include/ByteArray.kt @@ -12,6 +12,11 @@ class ByteArray(var size: Int) { init { this.data = malloc_array(kotlinclib_byte_size() * this.size) + var index = 0 + while (index < this.size) { + set(index, 0) + index = index + 1 + } } /** Returns the array element at the given [index]. This method can be called using the index operator. */ diff --git a/kotstd/include/IntArray.kt b/kotstd/include/IntArray.kt index 7003dd63a53..48e9e5fdb22 100644 --- a/kotstd/include/IntArray.kt +++ b/kotstd/include/IntArray.kt @@ -11,6 +11,11 @@ class IntArray(var size: Int) { init { this.data = malloc_array(kotlinclib_int_size() * this.size) + var index = 0 + while (index < this.size) { + set(index, 0) + index = index + 1 + } } /** Returns the array element at the given [index]. This method can be called using the index operator. */ diff --git a/kotstd/include/LongArray.kt b/kotstd/include/LongArray.kt index 683ce2130a2..210b22625b7 100644 --- a/kotstd/include/LongArray.kt +++ b/kotstd/include/LongArray.kt @@ -11,6 +11,11 @@ class LongArray(var size: Int) { init { this.data = malloc_array(kotlinclib_long_size() * this.size) + var index = 0 + while (index < this.size) { + set(index, 0) + index = index + 1 + } } /** Returns the array element at the given [index]. This method can be called using the index operator. */ diff --git a/kotstd/include/ShortArray.kt b/kotstd/include/ShortArray.kt index 5e2d8e97ea6..798fa96975f 100644 --- a/kotstd/include/ShortArray.kt +++ b/kotstd/include/ShortArray.kt @@ -11,6 +11,11 @@ class ShortArray(var size: Int) { init { this.data = malloc_array(kotlinclib_short_size() * this.size) + var index = 0 + while (index < this.size) { + set(index, 0) + index = index + 1 + } } /** Returns the array element at the given [index]. This method can be called using the index operator. */