Skip to content

Add mgp_result_reserve to C-API #1236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pages/custom-query-modules/c/c-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Memgraph in order to use them.
| enum [mgp_error](#variable-mgp-error) | **[mgp_path_equal](#function-mgp-path-equal)**(struct mgp_path * p1, struct mgp_path * p2, int * result)<br />Result is non-zero if given paths are equal, otherwise 0. |
| enum [mgp_error](#variable-mgp-error) | **[mgp_result_set_error_msg](#function-mgp-result-set-error-msg)**(struct mgp_result * res, const char * error_msg)<br />Set the error as the result of the procedure. |
| enum [mgp_error](#variable-mgp-error) | **[mgp_result_new_record](#function-mgp-result-new-record)**(struct mgp_result * res, struct mgp_result_record ** result)<br />Create a new record for results. |
| enum [mgp_error](#variable-mgp-error) | **[mgp_result_reserve](#function-mgp-result-reserve)**(struct mgp_result * res, size_t n)<br />Reserves memory for `n` result records. |
| enum [mgp_error](#variable-mgp-error) | **[mgp_result_record_insert](#function-mgp-result-record-insert)**(struct mgp_result_record * record, const char * field_name, struct mgp_value * val)<br />Assign a value to a field in the given record. |
| void | **[mgp_properties_iterator_destroy](#function-mgp-properties-iterator-destroy)**(struct mgp_properties_iterator * it)<br />Free the memory used by a mgp_properties_iterator. |
| enum [mgp_error](#variable-mgp-error) | **[mgp_properties_iterator_get](#function-mgp-properties-iterator-get)**(struct mgp_properties_iterator * it, struct [mgp_property](#mgp_property) ** result)<br />Get the current property pointed to by the iterator. |
Expand Down Expand Up @@ -1659,6 +1660,17 @@ Create a new record for results.

The previously obtained mgp_result_record pointer is no longer valid, and you must not use it. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_result_record.

### mgp_result_reserve [#function-mgp-result-reserve]
```cpp
enum mgp_error mgp_result_reserve(
struct mgp_result * res,
size_t n
)
```

Reserves memory for `n` result records.

Returns MGP_ERROR_UNABLE_TO_ALLOCATE if there's no memory for allocating the records.

### mgp_result_record_insert [#function-mgp-result-record-insert]
```cpp
Expand Down Expand Up @@ -4040,6 +4052,8 @@ enum mgp_error mgp_result_set_error_msg(struct mgp_result *res, const char *erro

enum mgp_error mgp_result_new_record(struct mgp_result *res, struct mgp_result_record **result);

enum mgp_error mgp_result_reserve(struct mgp_result *res, size_t n);

enum mgp_error mgp_result_record_insert(struct mgp_result_record *record, const char *field_name,
struct mgp_value *val);

Expand Down