- //Casts the ptr to a genericObjectSTruct so we can get to the ptr->allocsite field.
- cFile.append("struct genericObjectStruct * ptr = (struct genericObjectStruct *) InVar; if(InVar != NULL) { " + queryAndAddHashTableInC
- + "ptr); do { ");
-
- //This part of the code generates the switch statement from all objects in hash.
- cFile.append("switch(ptr->allocsite) { ");
- for (ConcreteRuntimeObjNode node : created.values()) {
- // If we haven't seen it and it's a node with more than 1 parent
- // Note: a node with 0 parents is a root node (i.e. inset variable)
- if (!done.contains(node.allocSite) && (node.getNumOfReachableParents() != 1 || node.isInsetVar)
- && node.decendantsConflict()) {
- addChecker(node, done, "ptr", 0);
- }
+ if(cases.size() == 0) {
+ cFile.append(" return; }");
+ }
+ else {
+ //Casts the ptr to a genericObjectStruct so we can get to the ptr->allocsite field.
+ cFile.append("struct genericObjectStruct * ptr = (struct genericObjectStruct *) InVar; if(InVar != NULL) { " + queryAndAddHashTableInC
+ + "ptr); do { ");
+
+ cFile.append("switch(ptr->allocsite) { ");
+
+ for(AllocSite singleCase: cases.keySet())
+ cFile.append(cases.get(singleCase));
+
+ cFile.append(" default : break; ");
+ cFile.append("}} while( (ptr = " + dequeueFromQueueInC + ") != NULL); ");
+
+ //Closes the method by clearing the Queue and reseting the hashTable to prevent
+ //overhead from freeing and mallocing the structures.
+ cFile.append(clearQueue + "; " + resetHashTable + "; }}\n");