diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/src/utils.c b/src/utils.c index d10f0f42..4b4bfb51 100644 --- a/src/utils.c +++ b/src/utils.c @@ -392,177 +392,6 @@ int assplode(const char *a, const char *delims, char ***pbits, return n; } -/** - * SECTION:reflitemlist - * @short_description: The index list and indexed arrays - * @title: ReflItemList - * @section_id: - * @see_also: - * @include: "utils.h" - * @Image: - * - * Wibble - */ - -struct _reflitemlist { - struct refl_item *items; - int n_items; - int max_items; -}; - - -void clear_items(ReflItemList *items) -{ - items->n_items = 0; -} - - -static void alloc_items(ReflItemList *items) -{ - items->items = realloc(items->items, - items->max_items*sizeof(struct refl_item)); -} - - -/** - * new_items: - * - * Creates a new %ReflItemList. - * - * Returns: The new list, or NULL. - **/ -ReflItemList *new_items() -{ - ReflItemList *new; - new = malloc(sizeof(ReflItemList)); - if ( new == NULL ) return NULL; - new->max_items = 1024; - new->n_items = 0; - new->items = NULL; - alloc_items(new); - return new; -} - - -void delete_items(ReflItemList *items) -{ - if ( items == NULL ) return; - if ( items->items != NULL ) free(items->items); - free(items); -} - - -void add_item_with_op(ReflItemList *items, signed int h, signed int k, - signed int l, int op) -{ - if ( items->n_items == items->max_items ) { - items->max_items += 1024; - alloc_items(items); - } - - items->items[items->n_items].h = h; - items->items[items->n_items].k = k; - items->items[items->n_items].l = l; - items->items[items->n_items].op = op; - items->n_items++; -} - - -void add_item(ReflItemList *items, signed int h, signed int k, signed int l) -{ - add_item_with_op(items, h, k, l, 0); -} - - -int find_item(ReflItemList *items, - signed int h, signed int k, signed int l) -{ - int i; - - for ( i=0; i<items->n_items; i++ ) { - if ( items->items[i].h != h ) continue; - if ( items->items[i].k != k ) continue; - if ( items->items[i].l != l ) continue; - return 1; - } - return 0; -} - - -static int find_op(ReflItemList *items, int op) -{ - int i; - - for ( i=0; i<items->n_items; i++ ) { - if ( items->items[i].op == op ) return 1; - } - return 0; -} - - -struct refl_item *get_item(ReflItemList *items, int i) -{ - if ( i >= items->n_items ) return NULL; - return &items->items[i]; -} - - -int num_items(const ReflItemList *items) -{ - return items->n_items; -} - - -void union_op_items(ReflItemList *items, ReflItemList *newi) -{ - int n, i; - - n = num_items(newi); - for ( i=0; i<n; i++ ) { - - struct refl_item *r = get_item(newi, i); - if ( find_op(items, r->op) ) continue; - - add_item_with_op(items, r->h, r->k, r->l, r->op); - - } -} - - -void union_items(ReflItemList *items, ReflItemList *newi) -{ - int n, i; - - n = num_items(newi); - for ( i=0; i<n; i++ ) { - - struct refl_item *r = get_item(newi, i); - if ( find_item(items, r->h, r->k, r->l) ) continue; - - add_item_with_op(items, r->h, r->k, r->l, r->op); - - } -} - - -ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2) -{ - int n, i; - ReflItemList *res = new_items(); - - n = num_items(i1); - for ( i=0; i<n; i++ ) { - - struct refl_item *r = get_item(i1, i); - if ( find_item(i2, r->h, r->k, r->l) ) { - add_item_with_op(res, r->h, r->k, r->l, r->op); - } - - } - - return res; -} - char *check_prefix(char *prefix) { |