aboutsummaryrefslogtreecommitdiff
path: root/src/cubeit.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-09-18 15:58:25 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:58 +0100
commit2c5b9563cbf4312ad7220c95da8842c5c75bf934 (patch)
tree021377dea9f976a0199f2e45bab0f2e819cf9c14 /src/cubeit.c
parent1f49bdeb4a788e3224876344a965fdc637bf8ffa (diff)
cubeit: Fixes
Diffstat (limited to 'src/cubeit.c')
-rw-r--r--src/cubeit.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/cubeit.c b/src/cubeit.c
index 11f4d555..ebe1bb5f 100644
--- a/src/cubeit.c
+++ b/src/cubeit.c
@@ -240,6 +240,7 @@ static void process_image(struct process_args *pargs)
}
free(image.data);
+ cell_free(pargs->cell);
if ( image.flags != NULL ) free(image.flags);
hdfile_close(hdfile);
}
@@ -591,16 +592,27 @@ int main(int argc, char *argv[])
/* Start threads off */
for ( i=0; i<nthreads; i++ ) {
- char line[1024];
struct process_args *pargs;
int r;
+ int rval;
+ char *filename;
+ UnitCell *cell;
pargs = worker_args[i];
- rval = fgets(line, 1023, fh);
- if ( rval == NULL ) continue;
- chomp(line);
- snprintf(pargs->filename, 1023, "%s%s", prefix, line);
+ /* Get the next filename */
+ rval = find_chunk(fh, &cell, &filename);
+ if ( rval == 1 ) break;
+ if ( config_basename ) {
+ char *tmp;
+ tmp = basename(filename);
+ free(filename);
+ filename = tmp;
+ }
+ snprintf(pargs->filename, 1023, "%s%s",
+ prefix, filename);
+ pargs->cell = cell;
+ free(filename);
n_images++;
@@ -657,6 +669,7 @@ int main(int argc, char *argv[])
snprintf(pargs->filename, 1023, "%s%s",
prefix, filename);
pargs->cell = cell;
+ free(filename);
n_images++;
@@ -668,9 +681,6 @@ int main(int argc, char *argv[])
pargs->start = 1;
pthread_mutex_unlock(&pargs->control_mutex);
- cell_free(cell);
- free(filename);
-
}
} while ( rval != NULL );