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

taosdata / TDengine / #3524

08 Nov 2024 04:27AM UTC coverage: 60.898% (+5.0%) from 55.861%
#3524

push

travis-ci

web-flow
Merge pull request #28647 from taosdata/fix/3.0/TD-32519_drop_ctb

fix TD-32519 drop child table with tsma caused crash

118687 of 248552 branches covered (47.75%)

Branch coverage included in aggregate %.

286 of 337 new or added lines in 18 files covered. (84.87%)

9647 existing lines in 190 files now uncovered.

199106 of 273291 relevant lines covered (72.85%)

15236719.35 hits per line

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

32.01
/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;
2,147,483,647✔
27
  int64_t  bsize = 0;
2,147,483,647✔
28
  uint8_t *pBuf = NULL;
2,147,483,647✔
29

30
  if (*ppBuf) {
2,147,483,647!
31
    pBuf = (*ppBuf) - sizeof(int64_t);
2,147,483,647✔
32
    bsize = *(int64_t *)pBuf;
2,147,483,647✔
33
  }
34

35
  if (bsize >= size) goto _exit;
2,147,483,647!
36

37
  if (bsize == 0) bsize = 64;
402,042,016!
38
  while (bsize < size) {
671,721,549!
39
    bsize *= 2;
269,679,533✔
40
  }
41

42
  pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
402,042,016✔
43
  if (pBuf == NULL) {
413,927,570!
44
    code = terrno;
51,421✔
UNCOV
45
    goto _exit;
×
46
  }
47

48
  *(int64_t *)pBuf = bsize;
413,876,298✔
49
  *ppBuf = pBuf + sizeof(int64_t);
413,876,298✔
50

51
_exit:
2,147,483,647✔
52
  return code;
2,147,483,647✔
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