Commits

Oleg Oshmyan committed a18e519

clean up APar_FindAtom

This reverts a part of changeset 613a10686cd8.
The memory corruption issue (see #5 in wez/atomicparsley)
is then resolved in a different way.

Comments (0)

Files changed (1)

 	AtomicInfo* thisAtom = NULL;
 	char* search_atom_name = (char*)atom_name;
 	char* reverse_dns_name = NULL;
-	short iter=0;
 	uint8_t revdns_name_len = 0;
 	uint8_t atom_index = 0; // if there are atoms mutliple identically named at the same level, this is where to store the count as it occurs
-	uint16_t desired_index = 1;
+	uint8_t desired_index = 1;
 	uint8_t search_atom_type = UNKNOWN_ATOM;
 	int known_atom = -1;
 	short search_atom_start_num = parsedAtoms[0].NextAtomNumber; //don't test 'ftyp'; its atom_number[0] & will be used to know when we have hit the end of the tree; can't hardcode it to '1' because ftyp's following atom can change; only ftyp as parsedAtoms[0] is guaranteed.
 	AtomicInfo* last_known_present_parent = NULL;
 	AtomicInfo atom_surrogate = { 0 };
 
-
 #if defined(DEBUG_V)
 	fprintf(stdout, "debug: AP_FindAtom entry trying to find '%s'; create missing: %u\n", atom_name, createMissing);
 #endif
 			reverse_dns_name = search_atom_name + 4+2; //4bytes atom name 2bytes ":["
 			revdns_name_len = portion_len-7; //4bytes atom name, 2 bytes ":[", 1 byte "]"
 			search_atom_type = atom_type;
-
 		} else if (search_atom_name[4] == '[') {
-			long sa_length=0;
-			char sa_at_5=NULL;
-			sa_length=strlen(search_atom_name);
-			sa_at_5=*(search_atom_name+5);
-
-			sscanf(search_atom_name+5, "%" PRIu16 "", &desired_index);
-
-
+			desired_index = strtoul(search_atom_name+5, NULL, 10);
 #if defined(DEBUG_V)
 			fprintf(stdout, "debug: AP_FindAtom     >#<indexed atom>#< '%s' at index=%u\n", search_atom_name, desired_index);
 #endif
 		APar_CreateSurrogateAtom(&atom_surrogate, search_atom_name, present_atomic_level, search_atom_type, atom_lang, reverse_dns_name, revdns_name_len);
 		atom_index = 0;
 
-		iter = search_atom_start_num;
+		short iter = search_atom_start_num;
 		while (true) {
 			AtomicInfo* result = NULL;
 
 						short total_root_level_atoms = APar_ReturnChildrenAtoms (0, 0);
 						short test_root_atom = 0;
 
-
 						//scan through all top level atoms
 						for(uint8_t root_atom_i = 1; root_atom_i <= total_root_level_atoms; root_atom_i++) {
 							test_root_atom = APar_ReturnChildrenAtoms (0, root_atom_i);
 					}
 				}
 				break;
-
 			} else if (iter == 0 && !createMissing) {
 					search_atom_name = NULL; //force the break;
 					break;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.