Changeset a42d7d8 in mainline for uspace/lib/bithenge/tree.c
- Timestamp:
- 2012-08-19T05:28:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fae4d30
- Parents:
- 1c79996
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/tree.c
r1c79996 ra42d7d8 90 90 { 91 91 get_for_each_data_t *data = (get_for_each_data_t *)raw_data; 92 bool equal = bithenge_node_equal(key, data->key); 92 bool equal; 93 int rc = bithenge_node_equal(&equal, key, data->key); 93 94 bithenge_node_dec_ref(key); 95 if (rc != EOK) 96 return rc; 94 97 if (equal) { 95 98 *data->out = value; … … 348 351 * internal nodes. Takes ownership of nothing. 349 352 * @memberof bithenge_node_t 353 * @param[out] out Holds whether the nodes are equal. 350 354 * @param a, b Nodes to compare. 351 * @return Whether the nodes are equal. If an error occurs, returns false.355 * @return EOK on success or an error code from errno.h. 352 356 * @todo Add support for internal nodes. 353 357 */ 354 bool bithenge_node_equal(bithenge_node_t *a, bithenge_node_t *b) 355 { 356 if (a->type != b->type) 357 return false; 358 int bithenge_node_equal(bool *out, bithenge_node_t *a, bithenge_node_t *b) 359 { 360 if (a->type != b->type) { 361 *out = false; 362 return EOK; 363 } 358 364 switch (a->type) { 359 365 case BITHENGE_NODE_INTERNAL: 360 return false; 366 *out = false; 367 return EOK; 361 368 case BITHENGE_NODE_BOOLEAN: 362 return a->boolean_value == b->boolean_value; 369 *out = a->boolean_value == b->boolean_value; 370 return EOK; 363 371 case BITHENGE_NODE_INTEGER: 364 return a->integer_value == b->integer_value; 372 *out = a->integer_value == b->integer_value; 373 return EOK; 365 374 case BITHENGE_NODE_STRING: 366 return !str_cmp(a->string_value.ptr, b->string_value.ptr); 375 *out = !str_cmp(a->string_value.ptr, b->string_value.ptr); 376 return EOK; 367 377 case BITHENGE_NODE_BLOB: 368 return bithenge_blob_equal( bithenge_node_as_blob(a),378 return bithenge_blob_equal(out, bithenge_node_as_blob(a), 369 379 bithenge_node_as_blob(b)); 370 380 } 371 return false;381 return EINVAL; 372 382 } 373 383
Note:
See TracChangeset
for help on using the changeset viewer.