Revert "fix undefined" (#19982)
Revert "fix undefined (#19960)" This reverts commit 032c3166e39ab333bf4803af40eb01d3535ec7a9.
Stelios Fragkakis committed
Mar 27, 2025 at 13:41 UTC
49dd93ef3228a976b6115072456856ea9b203b75
1 file changed
+17
-19
src/web/api/queries/rrdr.c
+17
-19
@@ -108,19 +108,9 @@ inline void rrdr_free(ONEWAYALLOC *owa, RRDR *r) {
108
}
109
110
RRDR *rrdr_create(ONEWAYALLOC *owa, QUERY_TARGET *qt, size_t dimensions, size_t points) {
111
- if(unlikely(!owa || !qt))
111
+ if(unlikely(!qt))
112
return NULL;
113
114
- if(unlikely(!dimensions)) {
115
- internal_error(true, "Attempted to create an RRDR with 0 dimensions.");
116
- return NULL;
117
- }
118
-
119
- if(unlikely(!points)) {
120
- internal_error(true, "Attempted to create an RRDR with 0 points.");
121
- return NULL;
122
- }
123
-
114
// create the rrdr
115
RRDR *r = onewayalloc_callocz(owa, 1, sizeof(RRDR));
116
r->internal.owa = owa;
@@ -132,14 +122,22 @@ RRDR *rrdr_create(ONEWAYALLOC *owa, QUERY_TARGET *qt, size_t dimensions, size_t
122
r->d = (int)dimensions;
123
r->n = (int)points;
124
135
- r->v = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
136
- r->o = onewayalloc_mallocz(owa, points * dimensions * sizeof(RRDR_VALUE_FLAGS));
137
- r->ar = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
138
- r->t = onewayalloc_callocz(owa, points, sizeof(time_t));
139
- r->od = onewayalloc_mallocz(owa, dimensions * sizeof(RRDR_DIMENSION_FLAGS));
140
- r->di = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
141
- r->dn = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
142
- r->du = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
125
+ if(points && dimensions) {
126
+ r->v = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
127
+ r->o = onewayalloc_mallocz(owa, points * dimensions * sizeof(RRDR_VALUE_FLAGS));
128
+ r->ar = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
129
+ }
130
+
131
+ if(points) {
132
+ r->t = onewayalloc_callocz(owa, points, sizeof(time_t));
133
+ }
134
+
135
+ if(dimensions) {
136
+ r->od = onewayalloc_mallocz(owa, dimensions * sizeof(RRDR_DIMENSION_FLAGS));
137
+ r->di = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
138
+ r->dn = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
139
+ r->du = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
140
+ }
141
142
r->view.group = 1;
143
r->view.update_every = 1;