Merge pull request #17203 from taosdata/fix/add_buffer_obj
fix: add buffer obj for further dev
This commit is contained in:
commit
13bee74a33
|
@ -27,6 +27,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SBuffer SBuffer;
|
||||
typedef struct SSchema SSchema;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
|
@ -56,6 +57,18 @@ const static uint8_t BIT2_MAP[4][4] = {{0b00000000, 0b00000001, 0b00000010, 0},
|
|||
#define SET_BIT2(p, i, v) ((p)[(i) >> 2] = (p)[(i) >> 2] & N1(BIT2_MAP[(i)&3][3]) | BIT2_MAP[(i)&3][(v)])
|
||||
#define GET_BIT2(p, i) (((p)[(i) >> 2] >> BIT2_MAP[(i)&3][3]) & ((uint8_t)3))
|
||||
|
||||
// SBuffer ================================
|
||||
struct SBuffer {
|
||||
int64_t nBuf;
|
||||
uint8_t *pBuf;
|
||||
};
|
||||
|
||||
#define tBufferCreate() \
|
||||
(SBuffer) { .nBuf = 0, .pBuf = NULL }
|
||||
void tBufferDestroy(SBuffer *pBuffer);
|
||||
int32_t tBufferInit(SBuffer *pBuffer, int64_t size);
|
||||
int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData);
|
||||
|
||||
// STSchema ================================
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
|
|
|
@ -20,6 +20,30 @@
|
|||
#include "tdatablock.h"
|
||||
#include "tlog.h"
|
||||
|
||||
// SBuffer ================================
|
||||
void tBufferDestroy(SBuffer *pBuffer) {
|
||||
tFree(pBuffer->pBuf);
|
||||
pBuffer->pBuf = NULL;
|
||||
}
|
||||
|
||||
int32_t tBufferInit(SBuffer *pBuffer, int64_t size) {
|
||||
pBuffer->nBuf = 0;
|
||||
return tRealloc(&pBuffer->pBuf, size);
|
||||
}
|
||||
|
||||
int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData) {
|
||||
int32_t code = 0;
|
||||
|
||||
code = tRealloc(&pBuffer->pBuf, pBuffer->nBuf + nData);
|
||||
if (code) return code;
|
||||
|
||||
memcpy(pBuffer->pBuf + pBuffer->nBuf, pData, nData);
|
||||
pBuffer->nBuf += nData;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// ================================
|
||||
static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson);
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
|
Loading…
Reference in New Issue