Exemplo n.º 1
0
   CHAR* _pmdController::allocFixBuf()
   {
      CHAR *pBuff = NULL ;

      _ctrlLatch.get() ;
      if ( _vecFixBuf.size() > 0 )
      {
         pBuff = _vecFixBuf.back() ;
         _vecFixBuf.pop_back() ;
      }
      _ctrlLatch.release() ;

      if ( pBuff )
      {
         goto done ;
      }

      pBuff = ( CHAR* )SDB_OSS_MALLOC( PMD_FIX_PTR_SIZE( _fixBufSize ) ) ;
      if ( !pBuff )
      {
         PD_LOG( PDERROR, "Alloc fix buff failed, size: %d",
                 PMD_FIX_PTR_SIZE( _fixBufSize ) ) ;
         goto error ;
      }
      PMD_FIX_PTR_HEADER( pBuff ) = _fixBufSize ;
      pBuff = PMD_FIX_PTR_TO_BUFF( pBuff ) ;

   done:
      return pBuff ;
   error:
      goto done ;
   }
Exemplo n.º 2
0
   CHAR* _pmdController::allocFixBuf()
   {
      CHAR *pBuff = NULL ;

      // if fix buff catch is not empty, get from catch
      _ctrlLatch.get() ;
      if ( _vecFixBuf.size() > 0 )
      {
         pBuff = _vecFixBuf.back() ;
         _vecFixBuf.pop_back() ;
      }
      _ctrlLatch.release() ;

      // if we still have free memory, let's just return the pointer
      if ( pBuff )
      {
         goto done ;
      }

      // memory will be freed in releaseFixBuf and fini
      pBuff = ( CHAR* )SDB_OSS_MALLOC( PMD_FIX_PTR_SIZE( _fixBufSize ) ) ;
      if ( !pBuff )
      {
         PD_LOG( PDERROR, "Alloc fix buff failed, size: %d",
                 PMD_FIX_PTR_SIZE( _fixBufSize ) ) ;
         goto error ;
      }
      PMD_FIX_PTR_HEADER( pBuff ) = _fixBufSize ;
      pBuff = PMD_FIX_PTR_TO_BUFF( pBuff ) ;

   done:
      return pBuff ;
   error:
      goto done ;
   }