Compare commits
	
		
			No commits in common. "3bbb476505b4d2f66c777c2c93b8086b7cbc3ae2" and "0451a89dce186c65c20788b0bd6863b634a4f7de" have entirely different histories.
		
	
	
		
			3bbb476505
			...
			0451a89dce
		
	
		
							
								
								
									
										2
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										2
									
								
								Makefile
								
								
								
								
							|  | @ -22,7 +22,7 @@ OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES)) | |||
| 
 | ||||
| CC = gcc | ||||
|   | ||||
| CFLAGS = -Wall -Werror -Wextra -g3 | ||||
| CFLAGS = -Wall -Werror -Wextra -g2 | ||||
| 
 | ||||
| LIB_NAME = libft | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								libft
								
								
								
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								libft
								
								
								
								
							|  | @ -1 +1 @@ | |||
| Subproject commit e846b98fcda5878a1d4d9de8f422dec09b97456c | ||||
| Subproject commit 1cab2379213f62f814312dc2cc7b0f3aa65268fc | ||||
							
								
								
									
										45
									
								
								src/nm.c
								
								
								
								
							
							
						
						
									
										45
									
								
								src/nm.c
								
								
								
								
							|  | @ -139,32 +139,24 @@ char *get_sym_char(Elf64_Sym sym, Elf64_Shdr sec) { | |||
| 	return ("n"); | ||||
| } | ||||
| 
 | ||||
| int strcmp_nm(void *a, void *b) { | ||||
| 	t_entry *aa = (t_entry *)a; | ||||
| 	t_entry *bb = (t_entry *)b; | ||||
| 	char *s1 = aa->symbol; | ||||
| 	char *s2 = bb->symbol; | ||||
| 	return ft_strcmp(s1, s2); | ||||
| } | ||||
| 
 | ||||
| int reverse(void *a, void *b) { | ||||
| 	return strcmp_nm(b, a); | ||||
| } | ||||
| 
 | ||||
| int nosort(void *a, void *b) { | ||||
| int strcmp_nm(t_list *a, t_list *b) { | ||||
| 	(void)a; | ||||
| 	(void)b; | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| void put_entry(void *data) { | ||||
| 	t_node *node = (t_node *)data; | ||||
| 	t_entry *entry = (t_entry *)node->data; | ||||
| 	ft_putstr(entry->string); | ||||
| int reverse(t_list *a, t_list *b) { | ||||
| 	return strcmp_nm(b, a); | ||||
| } | ||||
| 
 | ||||
| int nosort(t_list *a, t_list *b) { | ||||
| 	(void)a; | ||||
| 	(void)b; | ||||
| 	return -1; | ||||
| } | ||||
| 
 | ||||
| int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_ordering ordering) { | ||||
| 	t_root *tree = NULL; | ||||
| 	t_list *list = NULL; | ||||
| 	t_entry *entry = (t_entry *)malloc(sizeof(t_entry));  | ||||
| 	if (!entry) | ||||
| 		return FT_NM_FAILURE; | ||||
|  | @ -259,13 +251,13 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin | |||
| 					// ensuite un switch ordering avec un ft_lstinsert (pointeur sur fonction serait plus opti mais osef)
 | ||||
| 					switch (ordering) { | ||||
| 						case NOSORT: | ||||
| 							ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &nosort); | ||||
| 							ft_lstinsert(&list, ft_lstnew((void *)entry, sizeof(t_entry)), &nosort); | ||||
| 							break; | ||||
| 						case REVERSE: | ||||
| 							ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &reverse); | ||||
| 							ft_lstinsert(&list, ft_lstnew((void *)entry, sizeof(t_entry)), &reverse); | ||||
| 							break; | ||||
| 						case DEFAULT_ORDERING: | ||||
| 							ft_rbt_insert(&tree, ft_rbt_new((void *)entry, sizeof(t_entry)), &strcmp_nm); | ||||
| 							ft_lstinsert(&list, ft_lstnew((void *)entry, sizeof(t_entry)), &strcmp_nm); | ||||
| 							break; | ||||
| 					} | ||||
| 					// pas de bst oops :D
 | ||||
|  | @ -277,9 +269,14 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin | |||
| 		free(str); | ||||
| 	} | ||||
| 	// ici on affiche tout ou no symbols en cas de list vide
 | ||||
| 	if (tree) { | ||||
| 		ft_putrbt(tree, &put_entry); | ||||
| 	} else { | ||||
| 	if (list) { | ||||
| 		while (list) { | ||||
| 			t_entry *my_entry = (t_entry *)list->content; | ||||
| 			ft_putstr(my_entry->string); | ||||
| 			list = list->next; | ||||
| 		} | ||||
| 	} | ||||
| 	else { | ||||
| 		ft_printf("sss", "nm: ", path, ": no symbols\n"); | ||||
| 	} | ||||
| 	return FT_NM_SUCCESS; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue