refact
This commit is contained in:
parent
9e14eb778b
commit
b7112fc74b
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
|
|
||||||
#define TARRAY_MIN_SIZE 8
|
#define TARRAY_MIN_SIZE 8
|
||||||
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
|
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
|
||||||
|
#define TARRAY_ELEM_IDX(array, ele) (POINTER_DISTANCE(ele, (array)->pData) / (array)->elemSize)
|
||||||
|
|
||||||
typedef struct SArray {
|
typedef struct SArray {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -93,6 +94,14 @@ size_t taosArrayGetSize(const SArray* pArray);
|
||||||
*/
|
*/
|
||||||
void* taosArrayInsert(SArray* pArray, size_t index, void* pData);
|
void* taosArrayInsert(SArray* pArray, size_t index, void* pData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set data in array
|
||||||
|
* @param pArray
|
||||||
|
* @param index
|
||||||
|
* @param pData
|
||||||
|
*/
|
||||||
|
void* taosArraySet(SArray* pArray, size_t index, void* pData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove data entry of the given index
|
* remove data entry of the given index
|
||||||
* @param pArray
|
* @param pArray
|
||||||
|
|
|
@ -133,6 +133,11 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* taosArraySet(SArray* pArray, size_t index, void* pData) {
|
||||||
|
assert(index < pArray->size);
|
||||||
|
memcpy(TARRAY_GET_ELEM(pArray, index), pData, pArray->elemSize);
|
||||||
|
}
|
||||||
|
|
||||||
void taosArrayRemove(SArray* pArray, size_t index) {
|
void taosArrayRemove(SArray* pArray, size_t index) {
|
||||||
assert(index < pArray->size);
|
assert(index < pArray->size);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue