aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-07-13 11:57:21 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:53 +0100
commit5d0cae2baa9a7e09dd54b144cc503feac730794a (patch)
tree65b4bebe136811b78efd549484217b14eddca877 /src/utils.c
parent3c38652002e2793e5e6fc8115290a701fae9bb48 (diff)
Simplify symmetry and twinning quite a lot
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c
index 649d2b1c..1e54f923 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -292,17 +292,20 @@ struct _reflitemlist {
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));
}
+
ReflItemList *new_items()
{
ReflItemList *new;
@@ -314,14 +317,17 @@ ReflItemList *new_items()
return new;
}
+
void delete_items(ReflItemList *items)
{
+ if ( items == NULL ) return;
if ( items->items != NULL ) free(items->items);
free(items);
}
-void add_item(ReflItemList *items,
- signed int h, signed int k, signed int l)
+
+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;
@@ -331,9 +337,17 @@ void add_item(ReflItemList *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)
{
@@ -348,17 +362,20 @@ int find_item(ReflItemList *items,
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;
}
+
unsigned int *items_to_counts(ReflItemList *items)
{
unsigned int *c;