aboutsummaryrefslogtreecommitdiff
path: root/src/cell_explorer.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-08 16:49:22 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit230113ea3ff6efb2a52b91138e6295801b62603a (patch)
treeb850e88166473191ba2f79fdcb2185e77c3f539b /src/cell_explorer.c
parent13451f4933c75baf449df1e4a42d413b3336e351 (diff)
Convert cell_explorer to new Stream API
Diffstat (limited to 'src/cell_explorer.c')
-rw-r--r--src/cell_explorer.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/cell_explorer.c b/src/cell_explorer.c
index e481f85e..88c23dc3 100644
--- a/src/cell_explorer.c
+++ b/src/cell_explorer.c
@@ -1983,7 +1983,7 @@ int main(int argc, char *argv[])
return 1;
}
stream_filename = strdup(argv[optind]);
- st = open_stream_for_read(stream_filename);
+ st = stream_open_for_read(stream_filename);
if ( st == NULL ) {
fprintf(stderr, "Failed to open '%s'\n", stream_filename);
return 1;
@@ -1996,18 +1996,17 @@ int main(int argc, char *argv[])
w.n_cells = 0;
do {
- struct image cur;
+ struct image *image;
int i;
- if ( read_chunk(st, &cur, NULL, STREAM_READ_UNITCELL) != 0 ) {
- break;
- }
+ image = stream_read_chunk(st, NULL, STREAM_UNITCELL);
+ if ( image == NULL ) break;
- for ( i=0; i<cur.n_crystals; i++ ) {
+ for ( i=0; i<image->n_crystals; i++ ) {
Crystal *cr;
- cr = cur.crystals[i];
+ cr = image->crystals[i];
if ( w.n_cells == max_cells ) {
@@ -2041,7 +2040,7 @@ int main(int argc, char *argv[])
if ( !right_handed(w.cells[w.n_cells]) ) {
ERROR("WARNING: Left-handed cell encountered\n");
}
- w.indms[w.n_cells] = cur.indexed_by;
+ w.indms[w.n_cells] = image->indexed_by;
w.n_cells++;
crystal_free(cr);
@@ -2054,6 +2053,8 @@ int main(int argc, char *argv[])
w.n_cells, n_chunks);
}
+ image_free(image);
+
} while ( 1 );
fprintf(stderr, "Loaded %i cells from %i chunks\n", w.n_cells, n_chunks);
@@ -2070,7 +2071,7 @@ int main(int argc, char *argv[])
ERROR("To simplify matters, it's best to re-run indexamajig.\n");
ERROR("------------------\n");
}
- close_stream(st);
+ stream_close(st);
w.cols_on[0] = 1;
for ( i=1; i<8; i++ ) w.cols_on[i] = 2;