Memory management design and implementation. (#148)

This commit is contained in:
Nikolay Igotti
2016-12-27 15:01:18 +02:00
committed by GitHub
parent c9fbd37f90
commit e65b86ab21
14 changed files with 329 additions and 61 deletions
+7 -5
View File
@@ -1,4 +1,5 @@
#include <string.h>
#include "Memory.h"
#include "Natives.h"
#include "Types.h"
@@ -9,16 +10,15 @@ OBJ_GETTER(setupArgs, int argc, char** argv) {
// The count is one less, because we skip argv[0] which is the binary name.
AllocArrayInstance(theArrayTypeInfo, SCOPE_GLOBAL, argc - 1, OBJ_RESULT);
ArrayHeader* array = (*OBJ_RESULT)->array();
for (int index = 0; index < argc - 1; index++) {
AllocStringInstance(SCOPE_GLOBAL, argv[index + 1], strlen(argv[index + 1]),
ArrayAddressOfElementAt(array, index));
for (int index = 1; index < argc; index++) {
AllocStringInstance(SCOPE_GLOBAL, argv[index], strlen(argv[index]),
ArrayAddressOfElementAt(array, index - 1));
}
RETURN_OBJ_RESULT();
}
//--- main --------------------------------------------------------------------//
extern "C" void Konan_start(ObjHeader* );
extern "C" void Konan_start(const ObjHeader* );
int main(int argc, char** argv) {
@@ -31,6 +31,8 @@ int main(int argc, char** argv) {
Konan_start(args.obj());
}
DeinitMemory();
// Yes, we have to follow Java convention and return zero.
return 0;
}