Skip to content

Commit

Permalink
realloc_array: apply refactoring where it's appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlon Marshall committed Oct 29, 2024
1 parent 9e119b4 commit 9e270aa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ add_page( struct cache *c ) {
char **new_pages;
char *new_page;

new_pages = realloc_mem( c->pages, sizeof( char * ) * ( c->page_count + 1 ) );
new_pages = realloc_array( c->pages, ( c->page_count + 1 ), sizeof( char * ) );
if( !new_pages ) {
return -1;
}
Expand Down
7 changes: 1 addition & 6 deletions src/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,13 @@ struct stumpless_element *
stumpless_add_param( struct stumpless_element *element,
struct stumpless_param *param ) {
struct stumpless_param **new_params;
size_t old_params_size;
size_t new_params_size;

VALIDATE_ARG_NOT_NULL( element );
VALIDATE_ARG_NOT_NULL( param );

lock_element( element );

old_params_size = sizeof( param ) * element->param_count;
new_params_size = old_params_size + sizeof( param );

new_params = realloc_mem( element->params, new_params_size );
new_params = realloc_array( element->params, element->param_count, sizeof( struct stumpless_param * ) );
if( !new_params ) {
unlock_element( element );
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/target/journald.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void
init_fields( size_t field_count ) {
struct iovec *new_fields;

new_fields = realloc_mem( fields, sizeof( *fields ) * field_count );
new_fields = realloc_array( fields, field_count, sizeof( *fields ) );
if( !new_fields ) {
return;
}
Expand Down

0 comments on commit 9e270aa

Please sign in to comment.