mirror of
https://github.com/netdata/netdata.git
synced 2025-04-28 22:52:30 +00:00
fix undefined (#19960)
do not create empty rrdr Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
This commit is contained in:
parent
fb61cce652
commit
032c3166e3
1 changed files with 19 additions and 17 deletions
|
@ -108,9 +108,19 @@ inline void rrdr_free(ONEWAYALLOC *owa, RRDR *r) {
|
|||
}
|
||||
|
||||
RRDR *rrdr_create(ONEWAYALLOC *owa, QUERY_TARGET *qt, size_t dimensions, size_t points) {
|
||||
if(unlikely(!qt))
|
||||
if(unlikely(!owa || !qt))
|
||||
return NULL;
|
||||
|
||||
if(unlikely(!dimensions)) {
|
||||
internal_error(true, "Attempted to create an RRDR with 0 dimensions.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(unlikely(!points)) {
|
||||
internal_error(true, "Attempted to create an RRDR with 0 points.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create the rrdr
|
||||
RRDR *r = onewayalloc_callocz(owa, 1, sizeof(RRDR));
|
||||
r->internal.owa = owa;
|
||||
|
@ -122,22 +132,14 @@ RRDR *rrdr_create(ONEWAYALLOC *owa, QUERY_TARGET *qt, size_t dimensions, size_t
|
|||
r->d = (int)dimensions;
|
||||
r->n = (int)points;
|
||||
|
||||
if(points && dimensions) {
|
||||
r->v = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
|
||||
r->o = onewayalloc_mallocz(owa, points * dimensions * sizeof(RRDR_VALUE_FLAGS));
|
||||
r->ar = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
|
||||
}
|
||||
|
||||
if(points) {
|
||||
r->t = onewayalloc_callocz(owa, points, sizeof(time_t));
|
||||
}
|
||||
|
||||
if(dimensions) {
|
||||
r->od = onewayalloc_mallocz(owa, dimensions * sizeof(RRDR_DIMENSION_FLAGS));
|
||||
r->di = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
r->dn = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
r->du = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
}
|
||||
r->v = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
|
||||
r->o = onewayalloc_mallocz(owa, points * dimensions * sizeof(RRDR_VALUE_FLAGS));
|
||||
r->ar = onewayalloc_mallocz(owa, points * dimensions * sizeof(NETDATA_DOUBLE));
|
||||
r->t = onewayalloc_callocz(owa, points, sizeof(time_t));
|
||||
r->od = onewayalloc_mallocz(owa, dimensions * sizeof(RRDR_DIMENSION_FLAGS));
|
||||
r->di = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
r->dn = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
r->du = onewayalloc_callocz(owa, dimensions, sizeof(STRING *));
|
||||
|
||||
r->view.group = 1;
|
||||
r->view.update_every = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue