MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sparklineSequenceAddSample

Function sparklineSequenceAddSample

app/redis-6.2.6/src/sparkline.c:65–78  ·  view source on GitHub ↗

Add a new sample into a sequence. */

Source from the content-addressed store, hash-verified

63
64/* Add a new sample into a sequence. */
65void sparklineSequenceAddSample(struct sequence *seq, double value, char *label) {
66 label = (label == NULL || label[0] == '\0') ? NULL : zstrdup(label);
67 if (seq->length == 0) {
68 seq->min = seq->max = value;
69 } else {
70 if (value < seq->min) seq->min = value;
71 else if (value > seq->max) seq->max = value;
72 }
73 seq->samples = zrealloc(seq->samples,sizeof(struct sample)*(seq->length+1));
74 seq->samples[seq->length].value = value;
75 seq->samples[seq->length].label = label;
76 seq->length++;
77 if (label) seq->labels++;
78}
79
80/* Free a sequence. */
81void freeSparklineSequence(struct sequence *seq) {

Callers 1

Calls 2

zstrdupFunction · 0.85
zreallocFunction · 0.85

Tested by

no test coverage detected