[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] Changes to pspp/src/autorecode.c
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] Changes to pspp/src/autorecode.c |
Date: |
Thu, 03 Nov 2005 01:21:48 -0500 |
Index: pspp/src/autorecode.c
diff -u pspp/src/autorecode.c:1.23 pspp/src/autorecode.c:1.24
--- pspp/src/autorecode.c:1.23 Sat Oct 29 05:50:06 2005
+++ pspp/src/autorecode.c Thu Nov 3 06:21:46 2005
@@ -55,8 +55,7 @@
/* AUTORECODE transformation. */
struct autorecode_trns
{
- struct trns_header h;
- struct pool *owner; /* Contains AUTORECODE specs. */
+ struct pool *pool; /* Contains AUTORECODE specs. */
struct arc_spec *specs; /* AUTORECODE specifications. */
size_t spec_cnt; /* Number of specifications. */
};
@@ -222,20 +221,15 @@
static void
recode (const struct autorecode_pgm *arc)
{
- struct autorecode_trns *t;
- struct pool *pool;
+ struct autorecode_trns *trns;
size_t i;
- pool = pool_create ();
- t = xmalloc (sizeof *t);
- t->h.proc = autorecode_trns_proc;
- t->h.free = autorecode_trns_free;
- t->owner = pool;
- t->specs = pool_nalloc (t->owner, arc->var_cnt, sizeof *t->specs);
- t->spec_cnt = arc->var_cnt;
+ trns = pool_create_container (struct autorecode_trns, pool);
+ trns->specs = pool_nalloc (trns->pool, arc->var_cnt, sizeof *trns->specs);
+ trns->spec_cnt = arc->var_cnt;
for (i = 0; i < arc->var_cnt; i++)
{
- struct arc_spec *spec = &t->specs[i];
+ struct arc_spec *spec = &trns->specs[i];
void *const *p = hsh_sort (arc->src_values[i]);
int count = hsh_count (arc->src_values[i]);
int j;
@@ -252,30 +246,29 @@
for (j = 0; *p; p++, j++)
{
- struct arc_item *item = pool_alloc (t->owner, sizeof *item);
+ struct arc_item *item = pool_alloc (trns->pool, sizeof *item);
union value *vp = *p;
if (arc->src_vars[i]->type == NUMERIC)
item->from.f = vp->f;
else
- item->from.c = pool_strdup (t->owner, vp->c);
+ item->from.c = pool_strdup (trns->pool, vp->c);
item->to = arc->direction == ASCENDING ? j + 1 : count - j;
hsh_force_insert (spec->items, item);
}
}
- add_transformation (&t->h);
+ add_transformation (autorecode_trns_proc, autorecode_trns_free, trns);
}
static int
-autorecode_trns_proc (struct trns_header * trns, struct ccase * c,
- int case_idx UNUSED)
+autorecode_trns_proc (void *trns_, struct ccase *c, int case_idx UNUSED)
{
- struct autorecode_trns *t = (struct autorecode_trns *) trns;
+ struct autorecode_trns *trns = trns_;
size_t i;
- for (i = 0; i < t->spec_cnt; i++)
+ for (i = 0; i < trns->spec_cnt; i++)
{
- struct arc_spec *spec = &t->specs[i];
+ struct arc_spec *spec = &trns->specs[i];
struct arc_item *item;
union value v;
@@ -291,14 +284,14 @@
}
static void
-autorecode_trns_free (struct trns_header * trns)
+autorecode_trns_free (void *trns_)
{
- struct autorecode_trns *t = (struct autorecode_trns *) trns;
+ struct autorecode_trns *trns = trns_;
size_t i;
- for (i = 0; i < t->spec_cnt; i++)
- hsh_destroy (t->specs[i].items);
- pool_destroy (t->owner);
+ for (i = 0; i < trns->spec_cnt; i++)
+ hsh_destroy (trns->specs[i].items);
+ pool_destroy (trns->pool);
}
/* AUTORECODE procedure. */
- [Pspp-cvs] Changes to pspp/src/autorecode.c,
Ben Pfaff <=