Ignore:
Timestamp:
Nov 12, 2002, 6:07:48 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/storage32.c

    r8620 r9400  
    23212321   * Create the block chain abstractions.
    23222322   */
    2323   This->rootBlockChain =
    2324     BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL);
    2325 
    2326   This->smallBlockDepotChain = BlockChainStream_Construct(
    2327                                  This,
    2328                                  &This->smallBlockDepotStart,
    2329                                  PROPERTY_NULL);
     2323  if(!(This->rootBlockChain =
     2324       BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL)))
     2325    return STG_E_READFAULT;
     2326
     2327  if(!(This->smallBlockDepotChain =
     2328       BlockChainStream_Construct(This, &This->smallBlockDepotStart,
     2329                                  PROPERTY_NULL)))
     2330    return STG_E_READFAULT;
    23302331
    23312332  /*
     
    23812382  {
    23822383    /* TODO CLEANUP */
    2383     return E_FAIL;
     2384    return STG_E_READFAULT;
    23842385  }
    23852386
     
    23872388   * Create the block chain abstraction for the small block root chain.
    23882389   */
    2389   This->smallBlockRootChain = BlockChainStream_Construct(
    2390                                 This,
    2391                                 NULL,
    2392                                 This->rootPropertySetIndex);
     2390  if(!(This->smallBlockRootChain =
     2391       BlockChainStream_Construct(This, NULL, This->rootPropertySetIndex)))
     2392    return STG_E_READFAULT;
    23932393
    23942394  return hr;
     
    27312731 *          blockIndex - Index of the block to retrieve the chain
    27322732 *                       for.
     2733 *          nextBlockIndex - receives the return value.
    27332734 *
    27342735 * Returns: This method returns the index of the next block in the chain.
     
    27452746 * See Windows documentation for more details on IStorage methods.
    27462747 */
    2747 ULONG StorageImpl_GetNextBlockInChain(
     2748HRESULT StorageImpl_GetNextBlockInChain(
    27482749  StorageImpl* This,
    2749   ULONG          blockIndex)
     2750  ULONG        blockIndex,
     2751  ULONG*       nextBlockIndex)
    27502752{
    27512753  ULONG offsetInDepot    = blockIndex * sizeof (ULONG);
    27522754  ULONG depotBlockCount  = offsetInDepot / This->bigBlockSize;
    27532755  ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize;
    2754   ULONG nextBlockIndex   = BLOCK_SPECIAL;
    27552756  void* depotBuffer;
    27562757  ULONG depotBlockIndexPos;
    2757 
    2758   assert(depotBlockCount < This->bigBlockDepotCount);
     2758  int index;
     2759
     2760  *nextBlockIndex   = BLOCK_SPECIAL;
     2761
     2762  if(depotBlockCount >= This->bigBlockDepotCount)
     2763  {
     2764    WARN("depotBlockCount %ld, bigBlockDepotCount %ld\n", depotBlockCount,
     2765         This->bigBlockDepotCount);
     2766    return STG_E_READFAULT;
     2767  }
    27592768
    27602769  /*
     
    27792788    depotBuffer = StorageImpl_GetROBigBlock(This, depotBlockIndexPos);
    27802789
    2781     if (depotBuffer!=0)
    2782     {
    2783       int index;
    2784 
    2785       for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++)
    2786       {
    2787         StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &nextBlockIndex);
    2788         This->blockDepotCached[index] = nextBlockIndex;
    2789       }
    2790 
    2791       StorageImpl_ReleaseBigBlock(This, depotBuffer);
    2792     }
    2793   }
    2794 
    2795   nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)];
    2796 
    2797   return nextBlockIndex;
     2790    if (!depotBuffer)
     2791      return STG_E_READFAULT;
     2792
     2793    for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++)
     2794    {
     2795      StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), nextBlockIndex);
     2796      This->blockDepotCached[index] = *nextBlockIndex;
     2797    }
     2798    StorageImpl_ReleaseBigBlock(This, depotBuffer);
     2799  }
     2800
     2801  *nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)];
     2802
     2803  return S_OK;
    27982804}
    27992805
     
    30443050    StorageUtl_WriteWord(headerBigBlock,  0x1c, (WORD)-2);
    30453051    StorageUtl_WriteDWord(headerBigBlock, 0x38, (DWORD)0x1000);
    3046     StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);
    30473052  }
    30483053
     
    30503055   * Write the information to the header.
    30513056   */
    3052   if (headerBigBlock!=0)
    3053   {
    3054     StorageUtl_WriteWord(
    3055       headerBigBlock,
    3056       OFFSET_BIGBLOCKSIZEBITS,
    3057       This->bigBlockSizeBits);
    3058 
    3059     StorageUtl_WriteWord(
    3060       headerBigBlock,
    3061       OFFSET_SMALLBLOCKSIZEBITS,
    3062       This->smallBlockSizeBits);
    3063 
     3057  StorageUtl_WriteWord(
     3058    headerBigBlock,
     3059    OFFSET_BIGBLOCKSIZEBITS,
     3060    This->bigBlockSizeBits);
     3061
     3062  StorageUtl_WriteWord(
     3063    headerBigBlock,
     3064    OFFSET_SMALLBLOCKSIZEBITS,
     3065    This->smallBlockSizeBits);
     3066
     3067  StorageUtl_WriteDWord(
     3068    headerBigBlock,
     3069    OFFSET_BBDEPOTCOUNT,
     3070    This->bigBlockDepotCount);
     3071
     3072  StorageUtl_WriteDWord(
     3073    headerBigBlock,
     3074    OFFSET_ROOTSTARTBLOCK,
     3075    This->rootStartBlock);
     3076
     3077  StorageUtl_WriteDWord(
     3078    headerBigBlock,
     3079    OFFSET_SBDEPOTSTART,
     3080    This->smallBlockDepotStart);
     3081
     3082  StorageUtl_WriteDWord(
     3083    headerBigBlock,
     3084    OFFSET_SBDEPOTCOUNT,
     3085    This->smallBlockDepotChain ?
     3086     BlockChainStream_GetCount(This->smallBlockDepotChain) : 0);
     3087
     3088  StorageUtl_WriteDWord(
     3089    headerBigBlock,
     3090    OFFSET_EXTBBDEPOTSTART,
     3091    This->extBigBlockDepotStart);
     3092
     3093  StorageUtl_WriteDWord(
     3094    headerBigBlock,
     3095    OFFSET_EXTBBDEPOTCOUNT,
     3096    This->extBigBlockDepotCount);
     3097
     3098  for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
     3099  {
    30643100    StorageUtl_WriteDWord(
    30653101      headerBigBlock,
    3066       OFFSET_BBDEPOTCOUNT,
    3067       This->bigBlockDepotCount);
    3068 
    3069     StorageUtl_WriteDWord(
    3070       headerBigBlock,
    3071       OFFSET_ROOTSTARTBLOCK,
    3072       This->rootStartBlock);
    3073 
    3074     StorageUtl_WriteDWord(
    3075       headerBigBlock,
    3076       OFFSET_SBDEPOTSTART,
    3077       This->smallBlockDepotStart);
    3078 
    3079     StorageUtl_WriteDWord(
    3080       headerBigBlock,
    3081       OFFSET_EXTBBDEPOTSTART,
    3082       This->extBigBlockDepotStart);
    3083 
    3084     StorageUtl_WriteDWord(
    3085       headerBigBlock,
    3086       OFFSET_EXTBBDEPOTCOUNT,
    3087       This->extBigBlockDepotCount);
    3088 
    3089     for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
    3090     {
    3091       StorageUtl_WriteDWord(
    3092         headerBigBlock,
    3093         OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    3094         (This->bigBlockDepotStart[index]));
    3095     }
     3102      OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
     3103      (This->bigBlockDepotStart[index]));
    30963104  }
    30973105
     
    33823390                                           &bbHeadOfChain,
    33833391                                           PROPERTY_NULL);
    3384 
     3392  if(!bbTempChain) return NULL;
    33853393  /*
    33863394   * Grow the big block chain.
     
    41634171    newStream->tailIndex = blockIndex;
    41644172
    4165     blockIndex = StorageImpl_GetNextBlockInChain(
    4166                    parentStorage,
    4167                    blockIndex);
     4173    if(FAILED(StorageImpl_GetNextBlockInChain(
     4174              parentStorage,
     4175              blockIndex,
     4176              &blockIndex)))
     4177    {
     4178      HeapFree(GetProcessHeap(), 0, newStream);
     4179      return NULL;
     4180    }
    41684181  }
    41694182
     
    42264239    count++;
    42274240
    4228     blockIndex = StorageImpl_GetNextBlockInChain(
     4241    if(FAILED(StorageImpl_GetNextBlockInChain(
    42294242                   This->parentStorage,
    4230                    blockIndex);
     4243                   blockIndex,
     4244                   &blockIndex)))
     4245      return 0;
    42314246  }
    42324247
     
    42754290  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    42764291  {
    4277     blockIndex =
    4278       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4279 
     4292    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex)))
     4293      return FALSE;
    42804294    blockNoInSequence--;
    42814295  }
     
    43104324     * Step to the next big block.
    43114325     */
    4312     blockIndex    =
    4313       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
     4326    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex)))
     4327      return FALSE;
    43144328
    43154329    bufferWalker += bytesToReadInBuffer;
     
    43644378  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    43654379  {
    4366     blockIndex =
    4367       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4368 
     4380    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4381                                              &blockIndex)))
     4382      return FALSE;
    43694383    blockNoInSequence--;
    43704384  }
     
    43994413     * Step to the next big block.
    44004414     */
    4401     blockIndex    =
    4402       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4403 
     4415    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4416                                              &blockIndex)))
     4417      return FALSE;
    44044418    bufferWalker  += bytesToWrite;
    44054419    size          -= bytesToWrite;
     
    44444458  while (count < numBlocks)
    44454459  {
    4446     blockIndex =
    4447       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4448 
     4460    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4461                                              &blockIndex)))
     4462      return FALSE;
    44494463    count++;
    44504464  }
    44514465
    44524466  /* Get the next block before marking the new end */
    4453   extraBlock =
    4454     StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
     4467  if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4468                                            &extraBlock)))
     4469    return FALSE;
    44554470
    44564471  /* Mark the new end of chain */
     
    44684483  while (extraBlock != BLOCK_END_OF_CHAIN)
    44694484  {
    4470     blockIndex =
    4471       StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock);
    4472 
     4485    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock,
     4486                                              &blockIndex)))
     4487      return FALSE;
    44734488    StorageImpl_FreeBigBlock(This->parentStorage, extraBlock);
    44744489    extraBlock = blockIndex;
     
    45484563      currentBlock = blockIndex;
    45494564
    4550       blockIndex =
    4551         StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock);
     4565      if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock,
     4566                                                &blockIndex)))
     4567        return FALSE;
    45524568    }
    45534569
     
    47364752 *    - BLOCK_UNUSED: small block 'blockIndex' is free
    47374753 */
    4738 ULONG SmallBlockChainStream_GetNextBlockInChain(
     4754HRESULT SmallBlockChainStream_GetNextBlockInChain(
    47394755  SmallBlockChainStream* This,
    4740   ULONG                  blockIndex)
     4756  ULONG                  blockIndex,
     4757  ULONG*                 nextBlockInChain)
    47414758{
    47424759  ULARGE_INTEGER offsetOfBlockInDepot;
    47434760  DWORD  buffer;
    4744   ULONG  nextBlockInChain = BLOCK_END_OF_CHAIN;
    47454761  ULONG  bytesRead;
    47464762  BOOL success;
     4763
     4764  *nextBlockInChain = BLOCK_END_OF_CHAIN;
    47474765
    47484766  offsetOfBlockInDepot.s.HighPart = 0;
     
    47614779  if (success)
    47624780  {
    4763     StorageUtl_ReadDWord(&buffer, 0, &nextBlockInChain);
    4764   }
    4765 
    4766   return nextBlockInChain;
     4781    StorageUtl_ReadDWord(&buffer, 0, nextBlockInChain);
     4782    return S_OK;
     4783  }
     4784
     4785  return STG_E_READFAULT;
    47674786}
    47684787
     
    48694888      {
    48704889        sbdIndex = nextBlock;
    4871         nextBlock =
    4872           StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex);
     4890        StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex, &nextBlock);
    48734891      }
    48744892
     
    50075025  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    50085026  {
    5009     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    5010 
     5027    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5028                                                        &blockIndex)))
     5029      return FALSE;
    50115030    blockNoInSequence--;
    50125031  }
     
    50495068     * Step to the next big block.
    50505069     */
    5051     blockIndex    = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5070    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5071      return FALSE;
    50525072    bufferWalker += bytesToReadInBuffer;
    50535073    size         -= bytesToReadInBuffer;
     
    50955115  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    50965116  {
    5097     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    5098 
     5117    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5118      return FALSE;
    50995119    blockNoInSequence--;
    51005120  }
     
    51395159     * Step to the next big block.
    51405160     */
    5141     blockIndex    = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5161    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5162                                                        &blockIndex)))
     5163      return FALSE;
    51425164    bufferWalker  += bytesToWriteInBuffer;
    51435165    size          -= bytesToWriteInBuffer;
     
    51745196  while (count < numBlocks)
    51755197  {
    5176     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5198    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5199                                                        &blockIndex)))
     5200      return FALSE;
    51775201    count++;
    51785202  }
     
    52045228  {
    52055229    /* Get the next block before marking the new end */
    5206     extraBlock = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5230    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5231                                                        &extraBlock)))
     5232      return FALSE;
    52075233
    52085234    /* Mark the new end of chain */
     
    52185244  while (extraBlock != BLOCK_END_OF_CHAIN)
    52195245  {
    5220     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, extraBlock);
     5246    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, extraBlock,
     5247                                                        &blockIndex)))
     5248      return FALSE;
    52215249    SmallBlockChainStream_FreeBlock(This, extraBlock);
    52225250    extraBlock = blockIndex;
     
    52815309    oldNumBlocks++;
    52825310    currentBlock = blockIndex;
    5283     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, currentBlock);
     5311    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, currentBlock, &blockIndex)))
     5312      return FALSE;
    52845313  }
    52855314
     
    53215350    count++;
    53225351
    5323     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5352    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5353      return 0;
    53245354  }
    53255355
     
    57445774         newStorage,
    57455775         0,
    5746         0,
     5776         0,
    57475777         plkbyt,
    57485778         grfMode,
Note: See TracChangeset for help on using the changeset viewer.