Correct the bug for contiguous datatypes where 2 succesive calls to pack/unpack return the same buffer.
This commit was SVN r1010.
Этот коммит содержится в:
родитель
14974727a4
Коммит
87d36c72ec
@ -294,19 +294,24 @@ int lam_convertor_pack( lam_convertor_t* pConv, struct iovec* out, unsigned int
|
|||||||
if( pData->flags & DT_FLAG_CONTIGUOUS ) {
|
if( pData->flags & DT_FLAG_CONTIGUOUS ) {
|
||||||
if( pData->size == (extent = (pData->ub - pData->lb)) ) {
|
if( pData->size == (extent = (pData->ub - pData->lb)) ) {
|
||||||
size_t length = pData->size * pConv->count;
|
size_t length = pData->size * pConv->count;
|
||||||
|
char* pSrc = pConv->pBaseBuf + pData->true_lb + pConv->bConverted;
|
||||||
|
|
||||||
if( out[0].iov_base == NULL ) {
|
if( out[0].iov_base == NULL ) {
|
||||||
out[0].iov_base = pConv->pBaseBuf + pData->true_lb;
|
out[0].iov_base = pSrc;
|
||||||
if( (out[0].iov_base == 0) ||
|
if( (pConv->bConverted + out[0].iov_len) > length )
|
||||||
((pConv->bConverted + out[0].iov_len) > length) )
|
|
||||||
out[0].iov_len = length - pConv->bConverted;
|
out[0].iov_len = length - pConv->bConverted;
|
||||||
} else {
|
} else {
|
||||||
/* contiguous data just memcpy the smallest data in the user buffer */
|
/* contiguous data just memcpy the smallest data in the user buffer */
|
||||||
out[0].iov_len = IMIN( out[0].iov_len, pData->size * pConv->count );
|
out[0].iov_len = IMIN( out[0].iov_len, pData->size * pConv->count );
|
||||||
MEMCPY( out[0].iov_base, pConv->pBaseBuf + pData->true_lb, out[0].iov_len);
|
MEMCPY( out[0].iov_base, pSrc, out[0].iov_len);
|
||||||
}
|
}
|
||||||
pConv->bConverted += out[0].iov_len;
|
pConv->bConverted += out[0].iov_len;
|
||||||
return 0;
|
return (pConv->bConverted == length);
|
||||||
}
|
} else { /* datatype is contiguous but there are gap inbetween elements */
|
||||||
|
if( out[0].iov_base != NULL ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( out[0].iov_base == NULL ) {
|
if( out[0].iov_base == NULL ) {
|
||||||
out[0].iov_len = pConv->count * pData->size;
|
out[0].iov_len = pConv->count * pData->size;
|
||||||
|
@ -319,17 +319,15 @@ int lam_convertor_unpack( lam_convertor_t* pConvertor,
|
|||||||
if( pConvertor->flags & DT_FLAG_CONTIGUOUS ) {
|
if( pConvertor->flags & DT_FLAG_CONTIGUOUS ) {
|
||||||
if( pInputv[0].iov_base == NULL ) {
|
if( pInputv[0].iov_base == NULL ) {
|
||||||
rc = pConvertor->count * pData->size;
|
rc = pConvertor->count * pData->size;
|
||||||
|
pInputv[0].iov_base = pConvertor->pBaseBuf + pData->true_lb + pConvertor->bConverted;
|
||||||
if( pInputv[0].iov_len == 0 ) { /* give me the whole buffer */
|
if( pInputv[0].iov_len == 0 ) { /* give me the whole buffer */
|
||||||
pInputv[0].iov_base = pConvertor->pBaseBuf + pData->true_lb;
|
pInputv[0].iov_len = rc - pConvertor->bConverted;
|
||||||
pInputv[0].iov_len = rc;
|
|
||||||
return 1;
|
|
||||||
} else { /* what about the next chunk ? */
|
} else { /* what about the next chunk ? */
|
||||||
pInputv[0].iov_base = pConvertor->pBaseBuf + pData->true_lb + pConvertor->bConverted;
|
|
||||||
if( pInputv[0].iov_len > (rc - pConvertor->bConverted) )
|
if( pInputv[0].iov_len > (rc - pConvertor->bConverted) )
|
||||||
pInputv[0].iov_len = rc - pConvertor->bConverted;
|
pInputv[0].iov_len = rc - pConvertor->bConverted;
|
||||||
pConvertor->bConverted += pInputv[0].iov_len;
|
|
||||||
return (pConvertor->bConverted == rc);
|
|
||||||
}
|
}
|
||||||
|
pConvertor->bConverted += pInputv[0].iov_len;
|
||||||
|
return (pConvertor->bConverted == rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( (pInput >= pOutput) && (pInput < (pOutput + pConvertor->count * (pData->ub - pData->lb))) ) {
|
if( (pInput >= pOutput) && (pInput < (pOutput + pConvertor->count * (pData->ub - pData->lb))) ) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user