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

taosdata / TDengine / #3534

21 Nov 2024 07:36AM UTC coverage: 60.825% (+2.0%) from 58.848%
#3534

push

travis-ci

web-flow
Merge pull request #28810 from taosdata/ehn/add-sync-heartbeat-sent-time-to-log

ehn:add-sync-heartbeat-sent-time-to-log

120023 of 252376 branches covered (47.56%)

Branch coverage included in aggregate %.

43 of 47 new or added lines in 3 files covered. (91.49%)

2254 existing lines in 162 files now uncovered.

200876 of 275203 relevant lines covered (72.99%)

16110754.39 hits per line

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

30.67
/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;
413,248,384!
38
  while (bsize < size) {
681,229,178!
39
    bsize *= 2;
267,980,794✔
40
  }
41

42
  pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
413,248,384✔
43
  if (pBuf == NULL) {
422,259,881!
44
    code = terrno;
64,449✔
UNCOV
45
    goto _exit;
×
46
  }
47

48
  *(int64_t *)pBuf = bsize;
422,195,627✔
49
  *ppBuf = pBuf + sizeof(int64_t);
422,195,627✔
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