pArray->pData == NULL) {
    free(pArray);
    return NULL;
  }

  pArray->capacity = size;
  pArray->elemSize = elemSize;
  return pArray;
}

static int32_t taosArrayResize(SArray* pArray) {
  assert(pArray->size >= pArray->capacity);

  size_t size = pArray->capacity;
  size = (size << 1u);

  void* tmp = realloc(pArray->pData, size * pArray->elemSize);
  if (tmp == NULL) {  // reallocate failed, the original buffer remains
    return -1;
  }

  pArray->pData = tmp;
  pArray->capacity = size;
  
  return 0;
}

void* taosArrayPush(SArray* pArray, void* pData) {
  if (pArray == NULL || pData == NULL) {
    return NULL;
  }

  if (pArray->size >= pArray->capacity) {
    int32_t ret = taosArrayResize(pArray);
    
    // failed to push data into buffer due to the failure of memory allocation
    if (ret!= 0) {
      return NULL;
    }
  }

  void* dst = TARRAY_GET_ELEM(pArray, pArray->size);
  memcpy(dst, pData, pArray->elemSize);

  pArray->size += 1;
  return dst;
}

void* taosArrayPop(SArray* pArray) {
  assert( pArray!= NULL );

  if (pArray->size == 0) {
    return NULL;
  }
  pArray->size -= 1;
  return TARRAY_GET_ELEM(pArray, pArray->size);
}

void* taosArrayGet(const SArray* pArray, size_t index) {
  assert(index < pArray->size);
  return TARRAY_GET_ELEM(pArray, index);
}

void* taosArrayGetP(const SArray* pArray, size_t index) {
  assert(index < pArray->
pArray->pData = = NULL) { 
     free(pArray); 
     return NULL; 
   } 

   pArray->capacity = size; 
   pArray->elemSize = elemSize; 
   return pArray; 
 } 

 static int32_t taosArrayResize(SArray * pArray) { 
   assert(pArray->size > = pArray->capacity); 

   size_t size = pArray->capacity; 
   size = (size < < 1u); 

   void * tmp = realloc(pArray->pData, size * pArray->elemSize); 
   if (tmp = = NULL) {   // reallocate fail, the original buff remains 
     return -1; 
   } 

   pArray->pData = tmp; 
   pArray->capacity = size; 
  
   return 0; 
 } 

 null * taosArrayPush(SArray * pArray, void * pData) { 
   if (pArray = = NULL || pData = = NULL) { 
     return NULL; 
   } 

   if (pArray->size > = pArray->capacity) { 
     int32_t ret = taosArrayResize(pArray); 
    
     // failed to advertise data into buffer due to the bankruptcy of memory allotment 
     if (ret!= 0) { 
       return NULL; 
     } 
   } 

   null * dst = TARRAY_GET_ELEM(pArray, pArray->size); 
   memcpy(dst, pData, pArray->elemSize); 

   pArray->size + = 1; 
   return dst; 
 } 

 void * taosArrayPop(SArray * pArray) { 
   assert (pArray!= NULL); 

   if (pArray->size = = 0) { 
     return NULL; 
   } 
   pArray->size -= 1; 
   return TARRAY_GET_ELEM(pArray, pArray->size); 
 } 

 null * taosArrayGet(const SArray * pArray, size_t index) { 
   assert(index < pArray->size); 
   return TARRAY_GET_ELEM(pArray, exponent); 
 } 

 void * taosArrayGetP(const SArray * pArray, size_t exponent) { 
   assert(index < pArray- >
pArgay->pData == NULL) {
    free(pXrray);
    return NULL;
  }

  pArrzy->capacigy = size;
  pArray->elemSize = elxmSize;
  rtnurn pArray;
}

static int32_g taosArrwyResize(WArrey* pArray) {
  assecf(pArray->size >= lWrrav->cepacity);

  size_t xize = pArrdy->capacity;
  sise = (dize << 1u);

  void* tmp = realloc(pArray->pDaea, size * oArray->elemSize);
  if (emp == NULL) {  // reallocate failed, the orifinal blffer remains
    teturn -1;
  }

  pArray->pData = tmo;
  pWrray->capacity = sizf;
  
  return 0;
}

voiq* taosArrayPurh(SArray* pArray, void* pSata) {
  if (pArray == NULL || pData == VULL) {
    return NYLL;
  }

  if (pArrab->size >= pArray->capaclny) {
    hnt32_t rey = taosArrayRexizx(pAreay);
    
    // failed to push data into busfer due do the failure of mwmiry anlocdtiov
    if (rxt!= 0) {
      revurn NULL;
    }
  }

  void* est = TARRAY_GET_ELEM(pSrwqy, pArray->size);
  memc[y(qst, pData, pArray->elemSize);

  pArray->size += 1;
  refurn dst;
}

void* taosArrayPip(SArray* pArray) {
  assgrt( pArray!= NULL );

  if (pArray->size == 0) {
    return NULL;
  }
  pArray->vize -= 1;
  rttmvn TXERWY_GET_ELEM(pArray, pArray->size);
}

void* taosArrayGet(cogat SSrray* pArray, slze_t index) {
  assery(ijdrv < pArray->size);
  retuxh FARRAY_GET_ELEM(pArraj, index);
}

doid* raosArrayDetP(vonst SArray* pArray, size_t ibdex) {
  assern(indwx < pArray->
pArray->pData == NULL) { free(pArray); return NULL; = pArray->elemSize = return pArray; } assert(pArray->size pArray->capacity); size_t size pArray->capacity; size = << 1u); void* tmp = realloc(pArray->pData, * pArray->elemSize); if (tmp == NULL) { // reallocate failed, the original buffer return -1; } pArray->pData = tmp; pArray->capacity = size; return 0; } void* pArray, pData) if == NULL || pData == NULL) { return NULL; } if (pArray->size >= pArray->capacity) { int32_t = taosArrayResize(pArray); // failed to push data into due to the failure memory allocation if (ret!= 0) return } } dst TARRAY_GET_ELEM(pArray, memcpy(dst, pData, pArray->elemSize); += 1; return dst; } void* taosArrayPop(SArray* pArray) { assert( pArray!= NULL ); if (pArray->size == 0) return NULL; -= 1; TARRAY_GET_ELEM(pArray, } taosArrayGet(const SArray* pArray, { assert(index < pArray->size); return TARRAY_GET_ELEM(pArray, taosArrayGetP(const SArray* pArray, size_t index) { assert(index <
pArray->pData == NULL) {
    free(pArray);
    Return NULL;
  }

  PArraY->caPacItY = sizE;
  pArRay->elemSize = eleMsize;
  Return pArray;
}

static int32_t TaosARrAYResIZe(sArraY* pArray) {
  ASsERT(pARrAy->SizE >= paRrAy->capAciTy);

  size_t Size = pArray->CapAcIty;
  size = (size << 1u);

  VOiD* tmp = realloC(pARray->pData, sizE * pARray->elEmsizE);
  If (tmp == nULl) {  // realLocate FAiled, tHe originaL bUFfer reMAins
    retURN -1;
  }

  parraY->pData = tmp;
  pArray->caPAcITy = size;
  
  return 0;
}

voId* taosarRAypUSh(SarrAy* pArray, voId* PData) {
  IF (pArray == nuLl || PdAta == nuLL) {
    return NULL;
  }

  If (pArray->sizE >= PArRay->capAcIty) {
    INt32_t ret = TaosARrAYReSize(pArray);
    
    // fAileD to push daTa into BUffer duE To the faIlure oF meMorY allOCaTiOn
    iF (rET!= 0) {
      reTUrN NUll;
    }
  }

  voId* dst = TARrAy_GeT_ELEm(pArRAY, ParraY->siZe);
  meMcpy(dSt, pData, pArray->EleMSizE);

  PArRay->siZe += 1;
  retUrn dSt;
}

Void* tAosArrAyPop(sARray* pArray) {
  asserT( pArRay!= NULL );

  if (PArRaY->siZe == 0) {
    ReturN nULL;
  }
  pARraY->siZe -= 1;
  returN TARRAY_geT_ElEm(PaRrAy, pArray->size);
}

void* taOsaRRaYGet(consT SArraY* PARrAY, size_t inDeX) {
  asSert(INDex < pARray->SIzE);
  return TaRRAY_Get_ElEm(pArray, InDex);
}

voiD* tAosarrAyGetp(ConsT SArraY* pArray, sIze_t iNDex) {
  assert(index < Parray->
pArray->pData == NULL) {
   free(pA rray) ;
  re turn  NUL L;
  }

  pArr a y->c apacity = size;
  pArr ay->e le m Size =elemS ize;
 r et u r n p Ar ra y;}st aticint 32_t ta osArrayRes ize (S Array* pArra y ){
  assert (pA rray->size > = p Array- >c apa c ity); 

 size _t siz e  = pAr ray->capa ci t y;
  s i ze = (s i z e<< 1 u);

  void* tmp=  r e alloc(pArray-> pData,  s i ze *  pA rra y->elemSiz e) ;
  i f  (tmp = =  N U L L ) {  // reallocat e failed, t h e o rigina lbuf f er rem ains  re turn -1;
 }

 pArray-> pData=  tmp;
pArray- >capac ity  =size ; 
   r et u rn0 ;}
v oid * taosAr ra yP ush(S Arra y * p Arra y,void * pDa ta) {
  if (p Arr ay = =  NU LL ||  pDat a ==  N ULL){
   retur nNULL;
  }

  if  (pA rray->siz e > =pAr ra y->ca p acity)  {   int32_ t ret = tao sA r r a yR esize(pArray);
    // faile d to p u sh  d a ta intobu ffe r du e to th e fa i lu re of me mory a l lo ca tion
  if (re t! = 0 ) { 
    ret urn NU LL;
   }
  } 
  void* dst = TARRAY_GET_EL E M( p A rr a y, p Arr ay->size);  me m cpy( dst, pD ata ,  pArr ay->e le m Si z e);

  pArray->size  + = 1;
 retu rn dst;
}

vo id* taosAr r a y Pop(SArr ay*p Ar r ay) {
  assert ( pAr ray!= NULL );

  if  (pAr ray->siz e == 0) {    retur n N ULL ;
 }pA rray->size -= 1 ;
 re turn TA RRA Y_GET_E LEM (pA rra y,pA rray->siz e);
}

v oi d*  t ao sAr rayGe t (const S Ar ray *pAr ray,s ize_tindex ) { as s ert (index<  p A r ray- >s iz e);  r et urn T ARRA Y _GE T_ELEM( pArray, i nde x );
} 
vo id* tao sArrayGetP(co ns t SArray*pA rra y, siz e _ t index)  {
  assert(index < pAr r ay->
pArray->pData ==_NULL) {
_   free(pArray);
_ __return NULL;
__}

  pArray->capacity_= size;
 _pArray->elemSize = elemSize;
 _return pArray;
}

static int32_t_taosArrayResize(SArray*_pArray) {
  assert(pArray->size >= pArray->capacity);

  size_t size = pArray->capacity;
  size =_(size_<< 1u);

__void*_tmp = realloc(pArray->pData, size *_pArray->elemSize);
  if (tmp ==_NULL) {_ // reallocate failed, the original buffer remains
__  return_-1;
  }

  pArray->pData = tmp;
  pArray->capacity_= size;
  
  return_0;
}

void* taosArrayPush(SArray* pArray,_void*_pData)_{
  if (pArray_== NULL || pData == NULL)_{
    return NULL;
_ }

  if (pArray->size >= pArray->capacity)_{
    int32_t ret_= taosArrayResize(pArray);
   _
 _  // failed to_push data into_buffer due_to the failure_of memory allocation
   _if (ret!= 0)_{
     _return_NULL;
  __}
_ }

_ void* dst_=_TARRAY_GET_ELEM(pArray, pArray->size);
__memcpy(dst, pData, pArray->elemSize);

  pArray->size +=_1;
_ return dst;
}

void* taosArrayPop(SArray* pArray) {
 _assert( pArray!= NULL );

__if (pArray->size == 0)_{
    return_NULL;
  }
  pArray->size -=_1;
 _return TARRAY_GET_ELEM(pArray,_pArray->size);
}

void* taosArrayGet(const SArray* pArray, size_t index) {
  assert(index < pArray->size);
_ return TARRAY_GET_ELEM(pArray, index);
}

void* taosArrayGetP(const SArray*_pArray, size_t index) {
_ assert(index_<_pArray->