提交 b7112fc7 编写于 作者: H Hongze Cheng

refact

上级 9e14eb77
......@@ -25,6 +25,7 @@ extern "C" {
#define TARRAY_MIN_SIZE 8
#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 {
size_t size;
......@@ -93,6 +94,14 @@ size_t taosArrayGetSize(const SArray* pArray);
*/
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
* @param pArray
......
......@@ -133,6 +133,11 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
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) {
assert(index < pArray->size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册