| 44 | #include "file_found.h" |
| 45 | |
| 46 | alloc_data_t *file_found(alloc_data_t *current_search_space, const uint64_t offset, file_stat_t *file_stat) |
| 47 | { |
| 48 | if(current_search_space==NULL) |
| 49 | return current_search_space; |
| 50 | if(current_search_space->start == offset) |
| 51 | { |
| 52 | current_search_space->file_stat=file_stat; |
| 53 | current_search_space->data=1; |
| 54 | return current_search_space; |
| 55 | } |
| 56 | if(current_search_space->start < offset && offset <= current_search_space->end) |
| 57 | { |
| 58 | alloc_data_t *next_search_space; |
| 59 | next_search_space=(alloc_data_t*)MALLOC(sizeof(*next_search_space)); |
| 60 | memcpy(next_search_space, current_search_space, sizeof(*next_search_space)); |
| 61 | current_search_space->end=offset-1; |
| 62 | next_search_space->start=offset; |
| 63 | next_search_space->file_stat=file_stat; |
| 64 | next_search_space->data=1; |
| 65 | td_list_add(&next_search_space->list, ¤t_search_space->list); |
| 66 | return next_search_space; |
| 67 | } |
| 68 | return current_search_space; |
| 69 | } |
no test coverage detected