Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5c925ce in mainline for uspace/app/bithenge/blob.h


Ignore:
Timestamp:
2012-06-07T17:00:12Z (9 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
8375d0eb
Parents:
5f679702
Message:

Bithenge: make blobs a type of node

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/blob.h

    r5f679702 r5c925ce  
    3939
    4040#include <sys/types.h>
     41#include "tree.h"
    4142
    4243/** A blob of raw binary data. */
    4344typedef struct {
    4445        /** @privatesection */
    45         /** Operations providing random access. */
    46         const struct bithenge_random_access_blob_ops_t *ops;
     46        struct bithenge_node_t base;
    4747} bithenge_blob_t;
    4848
     
    121121{
    122122        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);
    125125}
    126126
     
    144144{
    145145        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);
    148148}
    149149
    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)
     150static inline bithenge_node_t *bithenge_blob_as_node(bithenge_blob_t *blob)
    156151{
    157         assert(blob);
    158         assert(blob->ops);
    159         return blob->ops->destroy(blob);
     152        return &blob->base;
     153}
     154
     155static inline bithenge_blob_t *bithenge_node_as_blob(bithenge_node_t *node)
     156{
     157        return (bithenge_blob_t *)node;
    160158}
    161159
     
    166164    const bithenge_sequential_blob_ops_t *ops);
    167165
    168 int bithenge_new_blob_from_data(bithenge_blob_t **out, const void *data,
     166int bithenge_new_blob_from_data(bithenge_node_t **out, const void *data,
    169167    size_t len);
    170168
    171 int bithenge_new_blob_from_buffer(bithenge_blob_t **out, const void *buffer,
     169int bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer,
    172170    size_t len, bool needs_free);
    173171
Note: See TracChangeset for help on using the changeset viewer.