From e9702ad37e4eff04543fe494585533132caeed5a Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Thu, 15 Feb 2024 17:36:05 +0900 Subject: [PATCH] Account for increased table sizes in getsizeof --- src/sys.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sys.c b/src/sys.c index c25c14a..ad61566 100644 --- a/src/sys.c +++ b/src/sys.c @@ -105,13 +105,13 @@ KRK_Function(getsizeof) { case KRK_OBJ_CLASS: { KrkClass * self = AS_CLASS(argv[0]); mySize += sizeof(KrkClass); - mySize += sizeof(KrkTableEntry) * self->methods.capacity; - mySize += sizeof(KrkTableEntry) * self->subclasses.capacity; + mySize += (sizeof(KrkTableEntry) + sizeof(ssize_t)) * self->methods.capacity; + mySize += (sizeof(KrkTableEntry) + sizeof(ssize_t)) * self->subclasses.capacity; break; } case KRK_OBJ_INSTANCE: { KrkInstance * self = AS_INSTANCE(argv[0]); - mySize += sizeof(KrkTableEntry) * self->fields.capacity; + mySize += (sizeof(KrkTableEntry) + sizeof(ssize_t)) * self->fields.capacity; KrkClass * type = krk_getType(argv[0]); mySize += type->allocSize; /* All instance types have an allocSize set */ @@ -119,7 +119,7 @@ KRK_Function(getsizeof) { if (krk_isInstanceOf(argv[0], vm.baseClasses->listClass)) { mySize += sizeof(KrkValue) * AS_LIST(argv[0])->capacity; } else if (krk_isInstanceOf(argv[0], vm.baseClasses->dictClass)) { - mySize += sizeof(KrkTableEntry) * AS_DICT(argv[0])->capacity; + mySize += (sizeof(KrkTableEntry) + sizeof(ssize_t)) * AS_DICT(argv[0])->capacity; } break; }