Skip to content

Commit

Permalink
(rasqal_new_row_from_row_deep): Add to deep copy row
Browse files Browse the repository at this point in the history
Does not deep copy the literals; just regular reference counting.
  • Loading branch information
dajobe committed Sep 20, 2023
1 parent d834c21 commit 8c21fd3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rasqal_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,7 @@ int rasqal_init_result_format_rdf(rasqal_world*);
/* rasqal_row.c */
rasqal_row* rasqal_new_row(rasqal_rowsource* rowsource);
rasqal_row* rasqal_new_row_from_row(rasqal_row* row);
rasqal_row* rasqal_new_row_from_row_deep(rasqal_row* row);
int rasqal_row_print(rasqal_row* row, FILE* fh);
int rasqal_row_write(rasqal_row* row, raptor_iostream* iostr);
raptor_sequence* rasqal_new_row_sequence(rasqal_world* world, rasqal_variables_table* vt, const char* const row_data[], int vars_count, raptor_sequence** vars_seq_p);
Expand Down
28 changes: 28 additions & 0 deletions src/rasqal_row.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,34 @@ rasqal_new_row_from_row(rasqal_row* row)
}


/**
* rasqal_new_row_from_row_deep:
* @row: query result row
*
* INTERNAL - Deep copy a query result row.
*
* Return value: a newly allocated query result row or NULL
*/
rasqal_row*
rasqal_new_row_from_row_deep(rasqal_row* row)
{
rasqal_row* new_row;

new_row = rasqal_new_row_common(row->rowsource->world, row->size, row->order_size);
if(row->values) {
int i;
for(i = 0; i < row->size; i++)
new_row->values[i] = rasqal_new_literal_from_literal(row->values[i]);
}
if(row->order_values) {
int i;
for(i = 0; i < row->order_size; i++)
new_row->order_values[i] = rasqal_new_literal_from_literal(row->order_values[i]);
}
return new_row;
}


/**
* rasqal_free_row:
* @row: query result row
Expand Down

0 comments on commit 8c21fd3

Please sign in to comment.