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

taosdata / TDengine / #3798

31 Mar 2025 10:39AM UTC coverage: 9.424% (-20.9%) from 30.372%
#3798

push

travis-ci

happyguoxy
test:add test cases

21549 of 307601 branches covered (7.01%)

Branch coverage included in aggregate %.

36084 of 303967 relevant lines covered (11.87%)

58620.7 hits per line

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

0.0
/include/util/tRealloc.h
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#ifndef _TD_UTIL_TREALLOC_H_
17
#define _TD_UTIL_TREALLOC_H_
18

19
#include "os.h"
20

21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24

25
static FORCE_INLINE int32_t tRealloc(uint8_t **ppBuf, int64_t size) {
26
  int32_t  code = 0;
×
27
  int64_t  bsize = 0;
×
28
  uint8_t *pBuf = NULL;
×
29

30
  if (*ppBuf) {
×
31
    pBuf = (*ppBuf) - sizeof(int64_t);
×
32
    bsize = *(int64_t *)pBuf;
×
33
  }
34

35
  if (bsize >= size) goto _exit;
×
36

37
  if (bsize == 0) bsize = 64;
×
38
  while (bsize < size) {
×
39
    bsize *= 2;
×
40
  }
41

42
  pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
×
43
  if (pBuf == NULL) {
×
44
    code = terrno;
×
45
    goto _exit;
×
46
  }
47

48
  *(int64_t *)pBuf = bsize;
×
49
  *ppBuf = pBuf + sizeof(int64_t);
×
50

51
_exit:
×
52
  return code;
×
53
}
54

55
#define tFree(BUF)                                        \
56
  do {                                                    \
57
    if (BUF) {                                            \
58
      taosMemoryFree((uint8_t *)(BUF) - sizeof(int64_t)); \
59
      (BUF) = NULL;                                       \
60
    }                                                     \
61
  } while (0)
62

63
#ifdef __cplusplus
64
}
65
#endif
66

67
#endif /*_TD_UTIL_TREALLOC_H_*/
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