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

taosdata / TDengine / #3529

14 Nov 2024 01:56PM UTC coverage: 60.888% (-0.02%) from 60.905%
#3529

push

travis-ci

web-flow
Merge pull request #28764 from taosdata/docs/TS-4937

doc(arch/last): new section for last/last_row cache

119990 of 252020 branches covered (47.61%)

Branch coverage included in aggregate %.

200800 of 274829 relevant lines covered (73.06%)

15624555.39 hits per line

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

32.16
/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;
371,685,889!
38
  while (bsize < size) {
625,543,635!
39
    bsize *= 2;
253,857,746✔
40
  }
41

42
  pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
371,685,889✔
43
  if (pBuf == NULL) {
381,748,705!
44
    code = terrno;
×
45
    goto _exit;
×
46
  }
47

48
  *(int64_t *)pBuf = bsize;
381,773,318✔
49
  *ppBuf = pBuf + sizeof(int64_t);
381,773,318✔
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