summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Gohad <tusharsg@gmail.com>2015-03-06 21:11:36 -0700
committerTushar Gohad <tusharsg@gmail.com>2015-03-06 21:11:36 -0700
commit4a9d7718c6644ee562cdd0d1e88325369d2e87e8 (patch)
treee38dc693b629bf8de24425ab3d575a0c3d73a5f3
parent676b5355e069d6e2135056e4af6fe45298b9b35d (diff)
parent16b49c501afb076ba2c18cb817e7fa50af926b87 (diff)
downloadpyeclib-4a9d7718c6644ee562cdd0d1e88325369d2e87e8.tar.gz
Merged in bloodeagle40234/pyeclib/fixes (pull request #19)
Use liberasurecode_get_fragment_size
-rw-r--r--src/c/pyeclib_c/pyeclib_c.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/c/pyeclib_c/pyeclib_c.c b/src/c/pyeclib_c/pyeclib_c.c
index 1830932..f46235d 100644
--- a/src/c/pyeclib_c/pyeclib_c.c
+++ b/src/c/pyeclib_c/pyeclib_c.c
@@ -215,8 +215,6 @@ pyeclib_c_get_segment_info(PyObject *self, PyObject *args)
int num_segments; /* total number of segments */
int fragment_size, last_fragment_size; /* fragment sizes in bytes */
int min_segment_size; /* EC algorithm's min. size (B) */
- int aligned_segment_size; /* size (B) adjusted for addr alignment */
- int aligned_data_len; /* size (B) adjusted for addr alignment */
/* Obtain and validate the method parameters */
if (!PyArg_ParseTuple(args, "Oii", &pyeclib_obj_handle, &data_len, &segment_size)) {
@@ -251,13 +249,10 @@ pyeclib_c_get_segment_info(PyObject *self, PyObject *args)
*/
/*
- * This will copmpute a size algined to the number of data
- * and the underlying wordsize of the EC algorithm.
+ * This will retrieve fragment_size calculated by liberasurecode with
+ * specified backend.
*/
- aligned_data_len = liberasurecode_get_aligned_data_size(pyeclib_handle->ec_desc, data_len);
-
- /* aligned_data_len is guaranteed to be divisible by k */
- fragment_size = aligned_data_len / pyeclib_handle->ec_args.k;
+ fragment_size = liberasurecode_get_fragment_size(pyeclib_handle->ec_desc, data_len);
/* Segment size is the user-provided segment size */
segment_size = data_len;
@@ -269,10 +264,7 @@ pyeclib_c_get_segment_info(PyObject *self, PyObject *args)
* the minimum segment size.
*/
- aligned_segment_size = liberasurecode_get_aligned_data_size(pyeclib_handle->ec_desc, segment_size);
-
- /* aligned_data_len is guaranteed to be divisible by k */
- fragment_size = aligned_segment_size / pyeclib_handle->ec_args.k;
+ fragment_size = liberasurecode_get_fragment_size(pyeclib_handle->ec_desc, segment_size);
last_segment_size = data_len - (segment_size * (num_segments - 1));
@@ -288,12 +280,9 @@ pyeclib_c_get_segment_info(PyObject *self, PyObject *args)
last_segment_size = last_segment_size + segment_size;
}
- aligned_segment_size = liberasurecode_get_aligned_data_size(pyeclib_handle->ec_desc, last_segment_size);
-
- /* Compute the last fragment size from the last segment size */
- last_fragment_size = aligned_segment_size / pyeclib_handle->ec_args.k;
+ last_fragment_size = liberasurecode_get_fragment_size(pyeclib_handle->ec_desc, last_segment_size);
}
-
+
/* Add header to fragment sizes */
last_fragment_size += sizeof(fragment_header_t);
fragment_size += sizeof(fragment_header_t);