diff options
author | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-02-05 20:15:57 -0800 |
---|---|---|
committer | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-02-27 15:44:37 +0900 |
commit | 57f5c565e64f8c33d3e299a8542de6d0f083b840 (patch) | |
tree | 2560935514eaa6b18c9f7752a6f60c2c3ae861e2 /src/erasurecode_helpers.c | |
parent | aa0c9605048153f640b8b871da9e483347e4b70f (diff) | |
download | liberasurecode-57f5c565e64f8c33d3e299a8542de6d0f083b840.tar.gz |
Ensure fragment pointers passed to cleanup
This patch achieves a couple of things as follows:
- Undoing the liberasurecode_encode_cleanup specification to
expect "fragment" pointers as its arguments.
- Ensuring liberasurecode_encode to pass "fratment" pointers to
liberasurecode_encode_cleanup.
liberasurecode_encode_cleanup is used also in pyeclib so that
it is expected that the argument pointers (i.e. encoded_data and
encoded_parity) should be the collection of the heads of "fragment"
pointers.
However, when the backend encode fails, liberasurecode keeps "data"
pointers behind of fragment_header, and then, goes to "out:" statement
to cleanup its memories. It causes invalid pointer failure.
This patch adds a translation function from "data" pointers to "fragment"
pointers and ensure liberasurecode_encode to pass correct pointers to
libersurecode_encode_cleanup.
Diffstat (limited to 'src/erasurecode_helpers.c')
-rw-r--r-- | src/erasurecode_helpers.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/erasurecode_helpers.c b/src/erasurecode_helpers.c index 94aa308..54e711b 100644 --- a/src/erasurecode_helpers.c +++ b/src/erasurecode_helpers.c @@ -232,6 +232,22 @@ int get_data_ptr_array_from_fragments(char **data_array, char **fragments, return num; } +int get_fragment_ptr_array_from_data(char **frag_array, char **data, + int num_data) +{ + int i = 0, num = 0; + for (i = 0; i < num_data; i++) { + char *data_ptr = frag_array[i]; + if (data_ptr == NULL) { + data[i] = NULL; + continue; + } + data[i] = get_fragment_ptr_from_data(data_ptr); + num++; + } + return num; +} + char *get_fragment_ptr_from_data_novalidate(char *buf) { buf -= sizeof(fragment_header_t); |