- \r
- // Truncate\r
- if (kcount != 0) {\r
- pk->size = --kcount;\r
- if ((pk->possibleKeys = (uint64_t *) realloc((void *)pk->possibleKeys, pk->size * sizeof(uint64_t))) == NULL) {\r
- PrintAndLog("Memory allocation error for pk->possibleKeys"); \r
- return 1;\r
- } \r
+ p3->even = 0; p3->odd = 0;\r
+ p4->even = 0; p4->odd = 0;\r
+ statelists[0].len = p3 - statelists[0].head.slhead;\r
+ statelists[1].len = p4 - statelists[1].head.slhead;\r
+ statelists[0].tail.sltail=--p3;\r
+ statelists[1].tail.sltail=--p4;\r
+\r
+ // the statelists now contain possible keys. The key we are searching for must be in the\r
+ // intersection of both lists. Create the intersection:\r
+ qsort(statelists[0].head.keyhead, statelists[0].len, sizeof(uint64_t), compar_int);\r
+ qsort(statelists[1].head.keyhead, statelists[1].len, sizeof(uint64_t), compar_int);\r
+\r
+ uint64_t *p5, *p6, *p7;\r
+ p5 = p7 = statelists[0].head.keyhead; \r
+ p6 = statelists[1].head.keyhead;\r
+ while (p5 <= statelists[0].tail.keytail && p6 <= statelists[1].tail.keytail) {\r
+ if (compar_int(p5, p6) == 0) {\r
+ *p7++ = *p5++;\r
+ p6++;\r
+ }\r
+ else {\r
+ while (compar_int(p5, p6) == -1) p5++;\r
+ while (compar_int(p5, p6) == 1) p6++;\r
+ }\r