Changed AllocStringInstance to accept data and length.
This commit is contained in:
committed by
alexander-gorshenev
parent
d0cd28fe5a
commit
0e7b13027e
@@ -9,7 +9,7 @@ ArrayHeader* setupArgs(int argc, char** argv) {
|
||||
ArrayHeader* args = AllocArrayInstance(theArrayTypeInfo, SCOPE_GLOBAL, argc-1);
|
||||
|
||||
for (int i = 0; i < argc-1; i++) {
|
||||
Kotlin_Array_set(args, i, AllocStringInstance( argv[i+1] ));
|
||||
Kotlin_Array_set(args, i, AllocStringInstance( argv[i+1], strlen(argv[i+1]) ));
|
||||
}
|
||||
|
||||
return args;
|
||||
|
||||
@@ -89,12 +89,11 @@ ArrayHeader* AllocArrayInstance(
|
||||
return ArrayContainer(type_info, elements).GetPlace();
|
||||
}
|
||||
|
||||
ArrayHeader* AllocStringInstance(const char* cstring) {
|
||||
uint32_t length = strlen(cstring);
|
||||
ArrayHeader* AllocStringInstance(const char* data, uint32_t length) {
|
||||
ArrayHeader* result = ArrayContainer(theStringTypeInfo, length).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
cstring,
|
||||
data,
|
||||
length);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ void InitMemory();
|
||||
ObjHeader* AllocInstance(const TypeInfo* type_info, PlacementHint hint);
|
||||
ArrayHeader* AllocArrayInstance(
|
||||
const TypeInfo* type_info, PlacementHint hint, uint32_t elements);
|
||||
ArrayHeader* AllocStringInstance(const char* cstring);
|
||||
ArrayHeader* AllocStringInstance(const char* data, uint32_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user