Changeset 5c925ce in mainline for uspace/app/bithenge/blob.h
- Timestamp:
- 2012-06-07T17:00:12Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8375d0eb
- Parents:
- 5f679702
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/blob.h
r5f679702 r5c925ce 39 39 40 40 #include <sys/types.h> 41 #include "tree.h" 41 42 42 43 /** A blob of raw binary data. */ 43 44 typedef struct { 44 45 /** @privatesection */ 45 /** Operations providing random access. */ 46 const struct bithenge_random_access_blob_ops_t *ops; 46 struct bithenge_node_t base; 47 47 } bithenge_blob_t; 48 48 … … 121 121 { 122 122 assert(blob); 123 assert(blob-> ops);124 return blob-> ops->size(blob, size);123 assert(blob->base.blob_ops); 124 return blob->base.blob_ops->size(blob, size); 125 125 } 126 126 … … 144 144 { 145 145 assert(blob); 146 assert(blob-> ops);147 return blob-> ops->read(blob, offset, buffer, size);146 assert(blob->base.blob_ops); 147 return blob->base.blob_ops->read(blob, offset, buffer, size); 148 148 } 149 149 150 /** Destroy the blob. 151 * @memberof bithenge_blob_t 152 * @param blob The blob. 153 * @return EOK on success or an error code from errno.h. 154 */ 155 static inline int bithenge_blob_destroy(bithenge_blob_t *blob) 150 static inline bithenge_node_t *bithenge_blob_as_node(bithenge_blob_t *blob) 156 151 { 157 assert(blob); 158 assert(blob->ops); 159 return blob->ops->destroy(blob); 152 return &blob->base; 153 } 154 155 static inline bithenge_blob_t *bithenge_node_as_blob(bithenge_node_t *node) 156 { 157 return (bithenge_blob_t *)node; 160 158 } 161 159 … … 166 164 const bithenge_sequential_blob_ops_t *ops); 167 165 168 int bithenge_new_blob_from_data(bithenge_ blob_t **out, const void *data,166 int bithenge_new_blob_from_data(bithenge_node_t **out, const void *data, 169 167 size_t len); 170 168 171 int bithenge_new_blob_from_buffer(bithenge_ blob_t **out, const void *buffer,169 int bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer, 172 170 size_t len, bool needs_free); 173 171
Note:
See TracChangeset
for help on using the changeset viewer.