Changeset 1923501 in mainline
- Timestamp:
- 2012-05-25T04:15:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce683ed3
- Parents:
- 743ce51
- Location:
- uspace/app/bithenge
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/blob.c
r743ce51 r1923501 84 84 } 85 85 86 static inline bithenge_sequential_blob_t *sequential_from_blob( 87 bithenge_blob_t *base) 88 { 89 return (bithenge_sequential_blob_t *)base; 90 } 91 92 static inline bithenge_blob_t *blob_from_sequential( 93 bithenge_sequential_blob_t *blob) 94 { 95 return &blob->base; 96 } 97 86 98 static int sequential_size(bithenge_blob_t *base, aoff64_t *size) 87 99 { 88 bithenge_sequential_blob_t *blob = (bithenge_sequential_blob_t *)base;100 bithenge_sequential_blob_t *blob = sequential_from_blob(base); 89 101 int rc; 90 102 if (blob->ops->size) { … … 108 120 char *buffer, aoff64_t *size) 109 121 { 110 bithenge_sequential_blob_t *blob = (bithenge_sequential_blob_t *)base;122 bithenge_sequential_blob_t *blob = sequential_from_blob(base); 111 123 aoff64_t end = offset + *size; 112 124 if (end > blob->data_size) { … … 124 136 static int sequential_destroy(bithenge_blob_t *base) 125 137 { 126 bithenge_sequential_blob_t *blob = (bithenge_sequential_blob_t *)base;138 bithenge_sequential_blob_t *blob = sequential_from_blob(base); 127 139 free(blob->buffer); 128 140 return blob->ops->destroy(blob); … … 151 163 // ops->size is optional 152 164 153 int rc = bithenge_new_random_access_blob(&blob->base, &sequential_ops); 165 int rc = bithenge_new_random_access_blob(blob_from_sequential(blob), 166 &sequential_ops); 154 167 if (rc != EOK) 155 168 return rc; -
uspace/app/bithenge/block.c
r743ce51 r1923501 51 51 } block_blob_t; 52 52 53 static inline block_blob_t *block_from_blob(bithenge_blob_t *base) 54 { 55 return (block_blob_t *)base; 56 } 57 58 static inline bithenge_blob_t *blob_from_block(block_blob_t *blob) 59 { 60 return &blob->base; 61 } 62 53 63 static int block_size(bithenge_blob_t *base, aoff64_t *size) 54 64 { 55 block_blob_t *blob = (block_blob_t *)base;65 block_blob_t *blob = block_from_blob(base); 56 66 *size = blob->size; 57 67 return EOK; … … 61 71 aoff64_t *size) 62 72 { 63 block_blob_t *blob = (block_blob_t *)base;73 block_blob_t *blob = block_from_blob(base); 64 74 if (offset > blob->size) 65 75 return ELIMIT; … … 70 80 static int block_destroy(bithenge_blob_t *base) 71 81 { 72 block_blob_t *blob = (block_blob_t *)base;82 block_blob_t *blob = block_from_blob(base); 73 83 block_fini(blob->service_id); 74 84 free(blob); … … 113 123 if (!blob) 114 124 return ENOMEM; 115 rc = bithenge_new_random_access_blob(&blob->base, &block_ops); 125 rc = bithenge_new_random_access_blob(blob_from_block(blob), 126 &block_ops); 116 127 if (rc != EOK) { 117 128 free(blob);
Note:
See TracChangeset
for help on using the changeset viewer.