Allocate a new file list. */
| 2940 | |
| 2941 | /* Allocate a new file list. */ |
| 2942 | static struct file_list *flist_new(int flags, const char *msg) |
| 2943 | { |
| 2944 | struct file_list *flist; |
| 2945 | |
| 2946 | flist = new0(struct file_list); |
| 2947 | |
| 2948 | if (flags & FLIST_TEMP) { |
| 2949 | if (!(flist->file_pool = pool_create(SMALL_EXTENT, 0, _out_of_memory, POOL_INTERN))) |
| 2950 | out_of_memory(msg); |
| 2951 | } else { |
| 2952 | /* This is a doubly linked list with prev looping back to |
| 2953 | * the end of the list, but the last next pointer is NULL. */ |
| 2954 | if (!first_flist) { |
| 2955 | if (!(flist->file_pool = pool_create(NORMAL_EXTENT, 0, _out_of_memory, POOL_INTERN))) |
| 2956 | out_of_memory(msg); |
| 2957 | |
| 2958 | flist->ndx_start = flist->flist_num = inc_recurse ? 1 : 0; |
| 2959 | |
| 2960 | first_flist = cur_flist = flist->prev = flist; |
| 2961 | } else { |
| 2962 | struct file_list *prev = first_flist->prev; |
| 2963 | |
| 2964 | flist->file_pool = first_flist->file_pool; |
| 2965 | |
| 2966 | flist->ndx_start = prev->ndx_start + prev->used + 1; |
| 2967 | flist->flist_num = prev->flist_num + 1; |
| 2968 | |
| 2969 | flist->prev = prev; |
| 2970 | prev->next = first_flist->prev = flist; |
| 2971 | } |
| 2972 | flist->pool_boundary = pool_boundary(flist->file_pool, 0); |
| 2973 | flist_cnt++; |
| 2974 | } |
| 2975 | |
| 2976 | return flist; |
| 2977 | } |
| 2978 | |
| 2979 | /* Free up all elements in a flist. */ |
| 2980 | void flist_free(struct file_list *flist) |
no test coverage detected