diff options
Diffstat (limited to 'libcrystfel/src/stream.c')
-rw-r--r-- | libcrystfel/src/stream.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 71dd7413..edbeb7af 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -453,7 +453,7 @@ int stream_write_chunk(Stream *st, const struct image *i, fprintf(st->fh, "hit = %i\n", i->hit); indexer = indexer_str(i->indexed_by); fprintf(st->fh, "indexed_by = %s\n", indexer); - free(indexer); + cffree(indexer); if ( i->indexed_by != INDEXING_NONE ) { fprintf(st->fh, "n_indexing_tries = %i\n", i->n_indexing_tries); } @@ -715,7 +715,7 @@ static void read_crystal(Stream *st, struct image *image, /* Add crystal to the list for this image */ n = image->n_crystals+1; - crystals_new = realloc(image->crystals, n*sizeof(Crystal *)); + crystals_new = cfrealloc(image->crystals, n*sizeof(Crystal *)); if ( crystals_new == NULL ) { ERROR("Failed to expand crystal list!\n"); @@ -733,7 +733,7 @@ static void parse_header(const char *line_in, struct image *image, char *line; char *pos; - line = strdup(line_in); + line = cfstrdup(line_in); chomp(line); pos = strchr(line, ' '); @@ -816,12 +816,12 @@ struct image *stream_read_chunk(Stream *st, StreamFlags srf) chomp(line); if ( strncmp(line, "Image filename: ", 16) == 0 ) { - image->filename = strdup(line+16); + image->filename = cfstrdup(line+16); have_filename = 1; } if ( strncmp(line, "Event: ", 7) == 0 ) { - image->ev = strdup(line+7); + image->ev = cfstrdup(line+7); } if ( strncmp(line, "hdf5/", 5) == 0 ) { @@ -928,7 +928,7 @@ struct image *stream_read_chunk(Stream *st, StreamFlags srf) char *stream_audit_info(Stream *st) { if ( st->audit_info == NULL ) return NULL; - return strdup(st->audit_info); + return cfstrdup(st->audit_info); } @@ -945,7 +945,7 @@ static int read_geometry_file(Stream *st) const size_t max_geom_len = 1024*1024; char *geom; - geom = malloc(max_geom_len); + geom = cfmalloc(max_geom_len); if ( geom == NULL ) { ERROR("Failed to allocate memory for geometry file\n"); return 1; @@ -962,7 +962,7 @@ static int read_geometry_file(Stream *st) if ( rval == NULL ) { ERROR("Failed to read stream geometry file.\n"); stream_close(st); - free(geom); + cffree(geom); return 1; } @@ -975,7 +975,7 @@ static int read_geometry_file(Stream *st) if ( len > max_geom_len-1 ) { ERROR("Stream's geometry file is too long (%li > %i).\n", (long)len, (int)max_geom_len); - free(geom); + cffree(geom); return 1; } else { strcat(geom, line); @@ -994,7 +994,7 @@ static int read_headers(Stream *st) int done = 0; size_t len = 0; - st->audit_info = malloc(4096); + st->audit_info = cfmalloc(4096); if ( st->audit_info == NULL ) { ERROR("Failed to allocate memory for audit information\n"); return 1; @@ -1041,7 +1041,7 @@ Stream *stream_open_for_read(const char *filename) { Stream *st; - st = malloc(sizeof(struct _stream)); + st = cfmalloc(sizeof(struct _stream)); if ( st == NULL ) return NULL; st->old_indexers = 0; st->audit_info = NULL; @@ -1058,7 +1058,7 @@ Stream *stream_open_for_read(const char *filename) } if ( st->fh == NULL ) { - free(st); + cffree(st); return NULL; } @@ -1108,7 +1108,7 @@ Stream *stream_open_fd_for_write(int fd, const DataTemplate *dtempl) { Stream *st; - st = malloc(sizeof(struct _stream)); + st = cfmalloc(sizeof(struct _stream)); if ( st == NULL ) return NULL; st->old_indexers = 0; st->audit_info = NULL; @@ -1120,7 +1120,7 @@ Stream *stream_open_fd_for_write(int fd, const DataTemplate *dtempl) st->fh = fdopen(fd, "w"); if ( st->fh == NULL ) { - free(st); + cffree(st); return NULL; } @@ -1165,7 +1165,7 @@ Stream *stream_open_for_write(const char *filename, { Stream *st; - st = malloc(sizeof(struct _stream)); + st = cfmalloc(sizeof(struct _stream)); if ( st == NULL ) return NULL; st->old_indexers = 0; st->audit_info = NULL; @@ -1178,7 +1178,7 @@ Stream *stream_open_for_write(const char *filename, st->fh = fopen(filename, "w"); if ( st->fh == NULL ) { ERROR("Failed to open stream.\n"); - free(st); + cffree(st); return NULL; } @@ -1209,11 +1209,11 @@ int stream_get_fd(Stream *st) void stream_close(Stream *st) { if ( st == NULL ) return; - free(st->audit_info); - free(st->geometry_file); + cffree(st->audit_info); + cffree(st->geometry_file); data_template_free(st->dtempl_read); fclose(st->fh); - free(st); + cffree(st); } @@ -1338,9 +1338,9 @@ struct _streamindex void stream_index_free(StreamIndex *index) { if ( index == NULL ) return; - free(index->keys); - free(index->ptrs); - free(index); + cffree(index->keys); + cffree(index->ptrs); + cffree(index); } @@ -1351,7 +1351,7 @@ static char *make_key(const char *filename, if ( ev == NULL ) ev = "//"; - key = malloc(strlen(filename)+strlen(ev)+2); + key = cfmalloc(strlen(filename)+strlen(ev)+2); if ( key == NULL ) return NULL; strcpy(key, filename); @@ -1398,14 +1398,14 @@ static void add_index_record(StreamIndex *index, char **new_keys; long int *new_ptrs; - new_keys = realloc(index->keys, - new_max_keys*sizeof(char *)); + new_keys = cfrealloc(index->keys, + new_max_keys*sizeof(char *)); if ( new_keys == NULL ) return; - new_ptrs = realloc(index->ptrs, - new_max_keys*sizeof(long int)); + new_ptrs = cfrealloc(index->ptrs, + new_max_keys*sizeof(long int)); if ( new_ptrs == NULL ) { - free(new_keys); + cffree(new_keys); return; } @@ -1436,7 +1436,7 @@ StreamIndex *stream_make_index(const char *filename) fh = fopen(filename, "r"); if ( fh == NULL ) return NULL; - index = malloc(sizeof(StreamIndex)); + index = cfmalloc(sizeof(StreamIndex)); if ( index == NULL ) { fclose(fh); return NULL; @@ -1467,11 +1467,11 @@ StreamIndex *stream_make_index(const char *filename) } if ( strncmp(line, "Image filename: ", 16) == 0 ) { - last_filename = strdup(line+16); + last_filename = cfstrdup(line+16); } if ( strncmp(line, "Event: ", 7) == 0 ) { - last_ev = strdup(line+7); + last_ev = cfstrdup(line+7); } if ( strcmp(line, STREAM_CHUNK_END_MARKER) == 0 ) { @@ -1483,8 +1483,8 @@ StreamIndex *stream_make_index(const char *filename) last_filename, last_ev); } - free(last_filename); - free(last_ev); + cffree(last_filename); + cffree(last_ev); last_start_pos = 0; last_filename = NULL; last_ev = NULL; |