Lines Matching refs:pKeys
567 void freeDataKeys(DataKeys* pKeys)
569 if (pKeys == NULL)
572 free(pKeys->fileData);
573 free(pKeys->threads);
574 free(pKeys->methods);
575 free(pKeys);
654 long parseVersion(DataKeys* pKeys, long offset, int verbose)
663 data = pKeys->fileData + offset;
664 dataEnd = pKeys->fileData + pKeys->fileLen;
703 return data - pKeys->fileData;
709 long parseThreads(DataKeys* pKeys, long offset)
718 data = pKeys->fileData + offset;
719 dataEnd = pKeys->fileData + pKeys->fileLen;
735 pKeys->threads = (ThreadEntry*) malloc(sizeof(ThreadEntry) * count);
736 if (pKeys->threads == NULL)
750 pKeys->threads[i].threadId = atoi(data);
751 pKeys->threads[i].threadName = data + tab +1;
756 pKeys->numThreads = count;
757 return data - pKeys->fileData;
763 long parseMethods(DataKeys* pKeys, long offset)
772 data = pKeys->fileData + offset;
773 dataEnd = pKeys->fileData + pKeys->fileLen;
794 pKeys->methods = (MethodEntry*) malloc(sizeof(MethodEntry) * count);
795 if (pKeys->methods == NULL)
797 initMethodEntry(&pKeys->methods[TOPLEVEL_INDEX], 0, "(toplevel)",
799 initMethodEntry(&pKeys->methods[UNKNOWN_INDEX], 0, "(unknown)",
853 initMethodEntry(&pKeys->methods[i], id, data + tab1 +1,
857 initMethodEntry(&pKeys->methods[i], id, data + tab1 +1,
861 initMethodEntry(&pKeys->methods[i], id, data + tab1 +1,
868 pKeys->numMethods = count;
869 return data - pKeys->fileData;
875 long parseEnd(DataKeys* pKeys, long offset)
884 data = pKeys->fileData + offset;
885 dataEnd = pKeys->fileData + pKeys->fileLen;
892 return data - pKeys->fileData;
904 void sortThreadList(DataKeys* pKeys)
906 qsort(pKeys->threads, pKeys->numThreads, sizeof(pKeys->threads[0]),
926 void sortMethodList(DataKeys* pKeys)
928 qsort(pKeys->methods, pKeys->numMethods, sizeof(MethodEntry),
937 DataKeys* pKeys = NULL;
941 pKeys = (DataKeys*) calloc(1, sizeof(DataKeys));
942 if (pKeys == NULL)
953 pKeys->fileLen = ftell(fp);
954 if (pKeys->fileLen == 0) {
960 pKeys->fileData = (char*) malloc(pKeys->fileLen);
961 if (pKeys->fileData == NULL) {
962 fprintf(stderr, "ERROR: unable to alloc %ld bytes\n", pKeys->fileLen);
966 if (fread(pKeys->fileData, 1, pKeys->fileLen, fp) != (size_t) pKeys->fileLen)
969 pKeys->fileLen);
975 offset = parseVersion(pKeys, offset, verbose);
976 offset = parseThreads(pKeys, offset);
977 offset = parseMethods(pKeys, offset);
978 offset = parseEnd(pKeys, offset);
983 pKeys->fileData = (char *)realloc(pKeys->fileData, offset);
984 pKeys->fileLen = offset;
988 sortThreadList(pKeys);
989 sortMethodList(pKeys);
995 printf("Threads (%d):\n", pKeys->numThreads);
996 for (i = 0; i < pKeys->numThreads; i++) {
998 pKeys->threads[i].threadId, pKeys->threads[i].threadName);
1007 printf("Methods (%d):\n", pKeys->numMethods);
1008 for (i = 0; i < pKeys->numMethods; i++) {
1010 pKeys->methods[i].methodId, pKeys->methods[i].className,
1011 pKeys->methods[i].methodName, pKeys->methods[i].signature);
1016 return pKeys;
1019 freeDataKeys(pKeys);
1102 MethodEntry* lookupMethod(DataKeys* pKeys, unsigned int methodId)
1108 hi = pKeys->numMethods - 1;
1113 id = pKeys->methods[mid].methodId;
1115 return &pKeys->methods[mid];
1177 DataKeys* pKeys = NULL;
1193 if ((pKeys = parseKeys(dataFp, 1)) == NULL)
1242 method = lookupMethod(pKeys, methodId);
1274 if (pKeys != NULL)
1275 freeDataKeys(pKeys);