Changeset 1c79996 in mainline for uspace/lib/bithenge/tree.c
- Timestamp:
- 2012-08-18T23:20:48Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a42d7d8
- Parents:
- 1f9c9a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/tree.c
r1f9c9a4 r1c79996 102 102 /** Get a child of a node. Takes ownership of the key. If the node does not 103 103 * provide this function, for_each will be used as an alternative, which may be 104 * very slow. 105 * @memberof bithenge_node_t 106 * @param self The internal node to find a child of. 104 * very slow. Also works for blob nodes to find the byte value at a given 105 * index. 106 * @memberof bithenge_node_t 107 * @param self The internal/blob node to find a child of. 107 108 * @param key The key to search for. 108 109 * @param[out] out Holds the found node. … … 112 113 bithenge_node_t **out) 113 114 { 115 if (self->type == BITHENGE_NODE_BLOB) { 116 if (bithenge_node_type(key) != BITHENGE_NODE_INTEGER) { 117 bithenge_node_dec_ref(key); 118 return ENOENT; 119 } 120 bithenge_int_t offset = bithenge_integer_node_value(key); 121 bithenge_node_dec_ref(key); 122 uint8_t byte; 123 aoff64_t size = 1; 124 int rc = bithenge_blob_read(bithenge_node_as_blob(self), 125 offset, (char *)&byte, &size); 126 if (rc != EOK) 127 return rc; 128 if (size != 1) 129 return ENOENT; 130 131 return bithenge_new_integer_node(out, byte); 132 } 133 114 134 assert(self->type == BITHENGE_NODE_INTERNAL); 115 135 if (self->internal_ops->get)
Note:
See TracChangeset
for help on using the changeset viewer.