add some more comments + fix indentation
@@ -379,6 +379,7 @@ javaReadClass(const unsigned char* classData)
classInfo->major_version = be16toh(*((uint16_t *)off)); off += 2;
classInfo->constant_pool_count = be16toh(*((uint16_t *)off)); off += 2;
classInfo->_constant_pool_count = classInfo->constant_pool_count;
+ //allocate memory for existing constant pool enties and make a room for up to 100 new entries
classInfo->constant_pool = (unsigned char **) calloc(100 + (classInfo->constant_pool_count - 1), sizeof(unsigned char *));
for(int i=1;i<classInfo->constant_pool_count;i++) {
classInfo->constant_pool[i - 1] = (unsigned char *)off;
@@ -392,7 +393,7 @@ javaReadClass(const unsigned char* classData)
classInfo->interfaces = (uint16_t *)off;
off += classInfo->interfaces_count * 2;
- //fields
+ //read fields
classInfo->fields_count = be16toh(*((uint16_t *)off)); off += 2;
classInfo->fields = (unsigned char **) calloc(classInfo->fields_count, sizeof(unsigned char *));
for (int i=0;i<classInfo->fields_count;i++) {
@@ -400,17 +401,19 @@ javaReadClass(const unsigned char* classData)
off += getAttributesLength(off + 6) + 6;
}
+ //read methods
classInfo->methods_count = be16toh(*((uint16_t *)off)); off += 2;
classInfo->_methods_count = classInfo->methods_count;
+ //allocate memory for existing methods and make a room for up to 100 new methods
classInfo->methods = (unsigned char **) calloc(100 + classInfo->methods_count, sizeof(unsigned char *));
for (int i=0;i<classInfo->methods_count;i++) {
classInfo->methods[i] = off;
off += javaGetMethodLength(off);
}
+ //read attributes
classInfo->attributes_count = be16toh(*((uint16_t *)off)); off += 2;
classInfo->attributes = (unsigned char **) calloc(classInfo->attributes_count, sizeof(unsigned char *));
-
for (int i=0;i<classInfo->attributes_count;i++) {
classInfo->attributes[i] = off;
uint32_t attribute_length = be32toh(*((uint32_t *)(off + 2)));
