Dico
12/13/2018, 12:58 PMmemScope {
val size = alloc<UIntVar>()
sysctlbyname(..., ..., size.ptr,)
size.value
}
nestserau
12/13/2018, 12:58 PMjonnyzzz
12/13/2018, 12:59 PMmemScope
block is completedDico
12/13/2018, 12:59 PMjonnyzzz
12/13/2018, 12:59 PMArena
or GlobalScope
for a loner-living thingsnestserau
12/13/2018, 1:14 PMmemScoped {
val size = alloc<ULongVar>()
sysctlbyname("hw.machine", null, size.ptr, null, 0)
val machine = allocArray<ByteVar>(size.value.toLong())
sysctlbyname("hw.machine", machine, size.ptr, null, 0)
return machine.getPointer(this).toKString()
}
Dico
12/13/2018, 1:31 PMDico
12/13/2018, 1:32 PMnestserau
12/13/2018, 1:33 PMsize_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char *)malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
nestserau
12/13/2018, 1:34 PMYou can replace getPointer(this) with ptrThis doesn’t work for
CArrayPointer
for some reason.Dico
12/13/2018, 1:34 PMnestserau
12/13/2018, 1:35 PMDico
12/13/2018, 1:35 PMnestserau
12/13/2018, 1:35 PMDico
12/13/2018, 1:36 PM