Changeset b7fd2a0 in mainline for uspace/lib/bithenge/src/blob.c
- Timestamp:
- 2018-01-13T03:10:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/blob.c
r36f0738 rb7fd2a0 49 49 * @return EOK on success or an error code from errno.h. 50 50 */ 51 int bithenge_init_random_access_blob(bithenge_blob_t *blob,51 errno_t bithenge_init_random_access_blob(bithenge_blob_t *blob, 52 52 const bithenge_random_access_blob_ops_t *ops) 53 53 { … … 67 67 } 68 68 69 static int sequential_buffer(bithenge_sequential_blob_t *blob, aoff64_t end)69 static errno_t sequential_buffer(bithenge_sequential_blob_t *blob, aoff64_t end) 70 70 { 71 71 bool need_realloc = false; … … 81 81 } 82 82 aoff64_t size = end - blob->data_size; 83 int rc = blob->ops->read(blob, blob->buffer + blob->data_size, &size);83 errno_t rc = blob->ops->read(blob, blob->buffer + blob->data_size, &size); 84 84 if (rc != EOK) 85 85 return rc; … … 100 100 } 101 101 102 static int sequential_size(bithenge_blob_t *base, aoff64_t *size)102 static errno_t sequential_size(bithenge_blob_t *base, aoff64_t *size) 103 103 { 104 104 bithenge_sequential_blob_t *blob = blob_as_sequential(base); 105 int rc;105 errno_t rc; 106 106 if (blob->ops->size) { 107 107 rc = blob->ops->size(blob, size); … … 121 121 } 122 122 123 static int sequential_read(bithenge_blob_t *base, aoff64_t offset,123 static errno_t sequential_read(bithenge_blob_t *base, aoff64_t offset, 124 124 char *buffer, aoff64_t *size) 125 125 { … … 127 127 aoff64_t end = offset + *size; 128 128 if (end > blob->data_size) { 129 int rc = sequential_buffer(blob, end);129 errno_t rc = sequential_buffer(blob, end); 130 130 if (rc != EOK) 131 131 return rc; … … 158 158 * @return EOK on success or an error code from errno.h. 159 159 */ 160 int bithenge_init_sequential_blob(bithenge_sequential_blob_t *blob,160 errno_t bithenge_init_sequential_blob(bithenge_sequential_blob_t *blob, 161 161 const bithenge_sequential_blob_ops_t *ops) 162 162 { … … 167 167 // ops->size is optional 168 168 169 int rc = bithenge_init_random_access_blob(sequential_as_blob(blob),169 errno_t rc = bithenge_init_random_access_blob(sequential_as_blob(blob), 170 170 &sequential_ops); 171 171 if (rc != EOK) … … 195 195 } 196 196 197 static int memory_size(bithenge_blob_t *base, aoff64_t *size)197 static errno_t memory_size(bithenge_blob_t *base, aoff64_t *size) 198 198 { 199 199 memory_blob_t *blob = blob_as_memory(base); … … 204 204 } 205 205 206 static int memory_read(bithenge_blob_t *base, aoff64_t offset, char *buffer,206 static errno_t memory_read(bithenge_blob_t *base, aoff64_t offset, char *buffer, 207 207 aoff64_t *size) 208 208 { … … 240 240 * function fails or the blob is destroyed. 241 241 * @return EOK on success or an error code from errno.h. */ 242 int bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer,242 errno_t bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer, 243 243 size_t len, bool needs_free) 244 244 { 245 int rc;245 errno_t rc; 246 246 assert(buffer || !len); 247 247 … … 278 278 * @param len The length of the data. 279 279 * @return EOK on success or an error code from errno.h. */ 280 int bithenge_new_blob_from_data(bithenge_node_t **out, const void *data,280 errno_t bithenge_new_blob_from_data(bithenge_node_t **out, const void *data, 281 281 size_t len) 282 282 { … … 309 309 } 310 310 311 static int subblob_size(bithenge_blob_t *base, aoff64_t *size)311 static errno_t subblob_size(bithenge_blob_t *base, aoff64_t *size) 312 312 { 313 313 subblob_t *blob = blob_as_subblob(base); … … 316 316 return EOK; 317 317 } else { 318 int rc = bithenge_blob_size(blob->source, size);318 errno_t rc = bithenge_blob_size(blob->source, size); 319 319 *size -= blob->offset; 320 320 return rc; … … 322 322 } 323 323 324 static int subblob_read(bithenge_blob_t *base, aoff64_t offset,324 static errno_t subblob_read(bithenge_blob_t *base, aoff64_t offset, 325 325 char *buffer, aoff64_t *size) 326 326 { … … 335 335 } 336 336 337 static int subblob_read_bits(bithenge_blob_t *base, aoff64_t offset,337 static errno_t subblob_read_bits(bithenge_blob_t *base, aoff64_t offset, 338 338 char *buffer, aoff64_t *size, bool little_endian) 339 339 { … … 368 368 } 369 369 370 static int new_subblob(bithenge_node_t **out, bithenge_blob_t *source,370 static errno_t new_subblob(bithenge_node_t **out, bithenge_blob_t *source, 371 371 aoff64_t offset, aoff64_t size, bool size_matters) 372 372 { 373 373 assert(out); 374 374 assert(source); 375 int rc;375 errno_t rc; 376 376 subblob_t *blob = 0; 377 377 … … 436 436 * @param offset The offset within the input blob at which the new blob will start. 437 437 * @return EOK on success or an error code from errno.h. */ 438 int bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *source,438 errno_t bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *source, 439 439 aoff64_t offset) 440 440 { … … 449 449 * @param size The size of the new blob. 450 450 * @return EOK on success or an error code from errno.h. */ 451 int bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *source,451 errno_t bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *source, 452 452 aoff64_t offset, aoff64_t size) 453 453 { … … 461 461 * @return EOK on success, or an error code from errno.h. 462 462 */ 463 int bithenge_blob_equal(bool *out, bithenge_blob_t *a, bithenge_blob_t *b)463 errno_t bithenge_blob_equal(bool *out, bithenge_blob_t *a, bithenge_blob_t *b) 464 464 { 465 465 assert(a); … … 467 467 assert(b); 468 468 assert(b->base.blob_ops); 469 int rc;469 errno_t rc; 470 470 char buffer_a[4096], buffer_b[4096]; 471 471 aoff64_t offset = 0, size_a = sizeof(buffer_a), size_b = sizeof(buffer_b);
Note:
See TracChangeset
for help on using the changeset viewer.