MCPcopy Create free account
hub / github.com/HelenOS/helenos / seq_node_subtransform

Function seq_node_subtransform

uspace/lib/bithenge/src/sequence.c:138–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static errno_t seq_node_subtransform(seq_node_t *self, bithenge_node_t **out,
139 size_t index)
140{
141 aoff64_t start_pos;
142 errno_t rc = seq_node_field_offset(self, &start_pos, index);
143 if (rc != EOK)
144 return rc;
145
146 bithenge_transform_t *subxform;
147 rc = self->ops->get_transform(self, &subxform, index);
148 if (rc != EOK)
149 return rc;
150
151 if (index == self->num_ends) {
152 /*
153 * We can apply the subtransform and cache its prefix length at
154 * the same time.
155 */
156 bithenge_node_t *blob_node;
157 bithenge_blob_inc_ref(self->blob);
158 rc = bithenge_new_offset_blob(&blob_node, self->blob,
159 start_pos);
160 if (rc != EOK) {
161 bithenge_transform_dec_ref(subxform);
162 return rc;
163 }
164
165 if (self->end_on_empty) {
166 bool empty;
167 rc = bithenge_blob_empty(
168 bithenge_node_as_blob(blob_node), &empty);
169 if (rc == EOK && empty) {
170 self->num_xforms = self->num_ends;
171 rc = ENOENT;
172 }
173 if (rc != EOK) {
174 bithenge_transform_dec_ref(subxform);
175 bithenge_node_dec_ref(blob_node);
176 return rc;
177 }
178 }
179
180 aoff64_t size;
181 rc = bithenge_transform_prefix_apply(subxform, self->scope,
182 bithenge_node_as_blob(blob_node), out, &size);
183 bithenge_node_dec_ref(blob_node);
184 bithenge_transform_dec_ref(subxform);
185 if (rc != EOK)
186 return rc;
187
188 if (self->num_xforms == -1) {
189 aoff64_t *new_ends = realloc(self->ends,
190 (self->num_ends + 1) * sizeof(*new_ends));
191 if (!new_ends)
192 return ENOMEM;
193 self->ends = new_ends;
194 }
195 self->ends[self->num_ends++] = start_pos + size;

Callers 5

struct_node_for_eachFunction · 0.85
struct_node_getFunction · 0.85
repeat_node_for_eachFunction · 0.85
repeat_node_getFunction · 0.85
do_while_node_for_eachFunction · 0.85

Calls 11

seq_node_field_offsetFunction · 0.85
bithenge_blob_inc_refFunction · 0.85
bithenge_new_offset_blobFunction · 0.85
bithenge_blob_emptyFunction · 0.85
bithenge_node_as_blobFunction · 0.85
bithenge_node_dec_refFunction · 0.85
bithenge_new_subblobFunction · 0.85
bithenge_transform_applyFunction · 0.85
reallocFunction · 0.50

Tested by

no test coverage detected