Changeset 7c3fb9b in mainline for uspace/lib/bithenge/src/sequence.c
- Timestamp:
- 2018-05-17T08:29:01Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6ff23ff
- Parents:
- fac0ac7
- git-author:
- Jiri Svoboda <jiri@…> (2018-05-16 17:28:17)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-05-17 08:29:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/sequence.c
rfac0ac7 r7c3fb9b 150 150 151 151 if (index == self->num_ends) { 152 /* We can apply the subtransform and cache its prefix length at 153 * the same time. */ 152 /* 153 * We can apply the subtransform and cache its prefix length at 154 * the same time. 155 */ 154 156 bithenge_node_t *blob_node; 155 157 bithenge_blob_inc_ref(self->blob); … … 418 420 struct_node_t *node = node_as_struct(base); 419 421 420 /* Treat the scope carefully because of the circular reference. In 422 /* 423 * Treat the scope carefully because of the circular reference. In 421 424 * struct_transform_make_node, things are set up so node owns a 422 425 * reference to the scope, but scope doesn't own a reference to node, 423 * so node's reference count is too low. */ 426 * so node's reference count is too low. 427 */ 424 428 bithenge_scope_t *scope = seq_node_scope(struct_as_seq(node)); 425 429 if (scope->refs == 1) { 426 /* Mostly normal destroy, but we didn't inc_ref(node) for the 430 /* 431 * Mostly normal destroy, but we didn't inc_ref(node) for the 427 432 * scope in struct_transform_make_node, so make sure it doesn't 428 * try to dec_ref. */ 433 * try to dec_ref. 434 */ 429 435 scope->current_node = NULL; 430 436 seq_node_destroy(struct_as_seq(node)); 431 437 } else if (scope->refs > 1) { 432 /* The scope is still needed, but node isn't otherwise needed. 438 /* 439 * The scope is still needed, but node isn't otherwise needed. 433 440 * Switch things around so scope owns a reference to node, but 434 * not vice versa, and scope's reference count is too low. */ 441 * not vice versa, and scope's reference count is too low. 442 */ 435 443 bithenge_node_inc_ref(base); 436 444 bithenge_scope_dec_ref(scope); 437 445 return; 438 446 } else { 439 /* This happens after the previous case, when scope is no 447 /* 448 * This happens after the previous case, when scope is no 440 449 * longer used and is being destroyed. Since scope is already 441 450 * being destroyed, set it to NULL here so we don't try to 442 * destroy it twice. */ 451 * destroy it twice. 452 */ 443 453 struct_as_seq(node)->scope = NULL; 444 454 seq_node_destroy(struct_as_seq(node)); … … 501 511 node->prefix = prefix; 502 512 503 /* We should inc_ref(node) here, but that would make a cycle. Instead, 513 /* 514 * We should inc_ref(node) here, but that would make a cycle. Instead, 504 515 * we leave it 1 too low, so that when the only remaining use of node 505 516 * is the scope, node will be destroyed. Also see the comment in 506 * struct_node_destroy. */ 517 * struct_node_destroy. 518 */ 507 519 bithenge_scope_set_current_node(inner, struct_as_node(node)); 508 520 bithenge_scope_dec_ref(inner); … … 591 603 * @param[out] out Stores the created transform. 592 604 * @param subtransforms The subtransforms and field names. 593 * @return EOK on success or an error code from errno.h. */ 605 * @return EOK on success or an error code from errno.h. 606 */ 594 607 errno_t bithenge_new_struct(bithenge_transform_t **out, 595 608 bithenge_named_transform_t *subtransforms) … … 869 882 * @param expr Used to calculate the number of times @a xform will be applied. 870 883 * May be NULL, in which case @a xform will be applied indefinitely. 871 * @return EOK on success or an error code from errno.h. */ 884 * @return EOK on success or an error code from errno.h. 885 */ 872 886 errno_t bithenge_repeat_transform(bithenge_transform_t **out, 873 887 bithenge_transform_t *xform, bithenge_expression_t *expr) … … 1114 1128 * @param expr Applied in the result of each application of @a xform to 1115 1129 * determine whether there will be more. 1116 * @return EOK on success or an error code from errno.h. */ 1130 * @return EOK on success or an error code from errno.h. 1131 */ 1117 1132 errno_t bithenge_do_while_transform(bithenge_transform_t **out, 1118 1133 bithenge_transform_t *xform, bithenge_expression_t *expr)
Note:
See TracChangeset
for help on using the changeset viewer.