1
1

Correct the bug for contiguous datatypes where 2 succesive calls to pack/unpack return the same buffer.

This commit was SVN r1010.
Этот коммит содержится в:
George Bosilca 2004-03-31 23:59:48 +00:00
родитель 14974727a4
Коммит 87d36c72ec
2 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -294,18 +294,23 @@ int lam_convertor_pack( lam_convertor_t* pConv, struct iovec* out, unsigned int
if( pData->flags & DT_FLAG_CONTIGUOUS ) {
if( pData->size == (extent = (pData->ub - pData->lb)) ) {
size_t length = pData->size * pConv->count;
char* pSrc = pConv->pBaseBuf + pData->true_lb + pConv->bConverted;
if( out[0].iov_base == NULL ) {
out[0].iov_base = pConv->pBaseBuf + pData->true_lb;
if( (out[0].iov_base == 0) ||
((pConv->bConverted + out[0].iov_len) > length) )
out[0].iov_base = pSrc;
if( (pConv->bConverted + out[0].iov_len) > length )
out[0].iov_len = length - pConv->bConverted;
} else {
/* contiguous data just memcpy the smallest data in the user buffer */
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;
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 ) {

Просмотреть файл

@ -319,19 +319,17 @@ int lam_convertor_unpack( lam_convertor_t* pConvertor,
if( pConvertor->flags & DT_FLAG_CONTIGUOUS ) {
if( pInputv[0].iov_base == NULL ) {
rc = pConvertor->count * pData->size;
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;
return 1;
} else { /* what about the next chunk ? */
pInputv[0].iov_base = pConvertor->pBaseBuf + pData->true_lb + pConvertor->bConverted;
if( pInputv[0].iov_len == 0 ) { /* give me the whole buffer */
pInputv[0].iov_len = rc - pConvertor->bConverted;
} else { /* what about the next chunk ? */
if( pInputv[0].iov_len > (rc - pConvertor->bConverted) )
pInputv[0].iov_len = rc - pConvertor->bConverted;
}
pConvertor->bConverted += pInputv[0].iov_len;
return (pConvertor->bConverted == rc);
}
}
}
if( (pInput >= pOutput) && (pInput < (pOutput + pConvertor->count * (pData->ub - pData->lb))) ) {
return 1;
}