We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b204d75 commit 1dc6a2aCopy full SHA for 1dc6a2a
1 file changed
src/store.c
@@ -366,17 +366,15 @@ int log_sample(DIR *proc,
366
367
ps->parent = parent;
368
369
- if (!parent->children) {
370
- /* it's the first child */
371
- parent->children = ps;
372
- } else {
373
- /* walk all children and append */
374
- struct ps_struct *children;
375
- children = parent->children;
376
- while (children->next)
377
- children = children->next;
378
-
379
- children->next = ps;
+ /*
+ * append ourselves to the list of children
+ * TODO: consider if prepending is OK for efficiency here.
+ */
+ {
+ struct ps_struct **children = &parent->children;
+ while (*children)
+ children = &(*children)->next;
+ *children = ps;
380
}
381
382
0 commit comments