Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3838

Show
Ignore:
Timestamp:
08/03/08 13:47:38 (4 months ago)
Author:
kris
Message:

fixes #1188 :: "Token is too large to fit within buffer" while using GrowBuffer?

Added an expand() method to take care of this. Kudos to fvbommel

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/io/Buffer.d

    r3598 r3838  
    710710                          else 
    711711                             // no more space in the buffer? 
    712                              if (writable is 0
     712                             if (writable is 0 && expand(0) is 0
    713713                                 error ("Token is too large to fit within buffer"); 
    714714 
     
    11121112                   extent += size; 
    11131113                   } 
     1114        } 
     1115 
     1116        /*********************************************************************** 
     1117 
     1118                Expand existing buffer space 
     1119 
     1120                Returns: 
     1121                Available space, without any expansion 
     1122 
     1123                Remarks: 
     1124                Make some additional room in the buffer, of at least the  
     1125                given size. This can be used by subclasses as appropriate 
     1126                                      
     1127        ***********************************************************************/ 
     1128 
     1129        protected uint expand (uint size) 
     1130        { 
     1131                return writable; 
    11141132        } 
    11151133 
     
    15181536 
    15191537                   if (size + index > dimension) 
    1520                        makeRoom (size); 
     1538                       expand (size); 
    15211539 
    15221540                   // populate tail of buffer with new content 
     
    15431561        {                
    15441562                if (length > writable) 
    1545                     makeRoom (length); 
     1563                    expand (length); 
    15461564 
    15471565                copy (src, length); 
     
    15611579        { 
    15621580                if (writable <= increment/8) 
    1563                     makeRoom (increment); 
     1581                    expand (increment); 
    15641582 
    15651583                return write (&src.read); 
     
    15851603        /*********************************************************************** 
    15861604 
    1587                 make some room in the buffer 
    1588                          
    1589         ***********************************************************************/ 
    1590  
    1591         private uint makeRoom (uint size) 
     1605                Expand existing buffer space 
     1606 
     1607                Returns: 
     1608                Available space after adjustment 
     1609 
     1610                Remarks: 
     1611                Make some additional room in the buffer, of at least the  
     1612                given size. This can be used by subclasses as appropriate 
     1613                                      
     1614        ***********************************************************************/ 
     1615 
     1616        override uint expand (uint size) 
    15921617        { 
    15931618                if (size < increment) 
     
    15961621                dimension += size; 
    15971622                data.length = dimension;                
    1598                 return writable()
     1623                return writable
    15991624        } 
    16001625}