• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4986

15 Mar 2026 08:32AM UTC coverage: 37.305% (-31.3%) from 68.601%
#4986

push

travis-ci

tomchon
test: keep docs and unit test

125478 of 336361 relevant lines covered (37.3%)

1134847.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contrib/TSZ/sz/src/DynamicByteArray.c
1
/**
2
 *  @file DynamicByteArray.c
3
 *  @author Sheng Di
4
 *  @date May, 2016
5
 *  @brief Dynamic Byte Array
6
 *  (C) 2015 by Mathematics and Computer Science (MCS), Argonne National Laboratory.
7
 *      See COPYRIGHT in top-level directory.
8
 */
9

10
#include <stdlib.h> 
11
#include <stdio.h>
12
#include <string.h>
13
#include "DynamicByteArray.h"
14
#include "sz.h"
15

16
void new_DBA(DynamicByteArray **dba, size_t cap) {
×
17
                *dba = (DynamicByteArray *)malloc(sizeof(DynamicByteArray));
×
18
        (*dba)->size = 0;
×
19
        (*dba)->capacity = cap;
×
20
        (*dba)->array = (unsigned char*)malloc(sizeof(unsigned char)*cap);
×
21
}
×
22

23
void convertDBAtoBytes(DynamicByteArray *dba, unsigned char** bytes)
×
24
{
25
        size_t size = dba->size;
×
26
        if(size>0)
×
27
                *bytes = (unsigned char*)malloc(size * sizeof(unsigned char));
×
28
        else
29
        {
30
            *bytes = NULL;
×
31
                return ;
×
32
        }
33
        memcpy(*bytes, dba->array, size*sizeof(unsigned char));        
×
34
}
35

36
void free_DBA(DynamicByteArray *dba)
×
37
{
38
        free(dba->array);
×
39
        free(dba);
×
40
}
×
41

42
INLINE unsigned char getDBA_Data(DynamicByteArray *dba, size_t pos)
×
43
{
44
        if(pos>=dba->size)
×
45
        {
46
                printf("Error: wrong position of DBA (impossible case unless bugs elsewhere in the code?).\n");
×
47
                exit(0);
×
48
        }
49
        return dba->array[pos];
×
50
}
51

52
INLINE void addDBA_Data(DynamicByteArray *dba, unsigned char value)
×
53
{
54
        if(dba->size==dba->capacity)
×
55
        {
56
                dba->capacity = dba->capacity << 1;
×
57
                dba->array = (unsigned char *)realloc(dba->array, dba->capacity*sizeof(unsigned char));
×
58
        }
59
        dba->array[dba->size] = value;
×
60
        dba->size ++;
×
61
}
×
62

63
INLINE void memcpyDBA_Data(DynamicByteArray *dba, unsigned char* data, size_t length)
×
64
{
65
        if(dba->size + length > dba->capacity)
×
66
        {
67
                dba->capacity = dba->size + length;
×
68
                dba->array = (unsigned char *)realloc(dba->array, dba->capacity*sizeof(unsigned char));
×
69
        }
70
        memcpy(&(dba->array[dba->size]), data, length);
×
71
        dba->size += length;
×
72
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc