@@ -174,32 +174,16 @@ class Block {
174174 return inner_size - sizeof (prev_) + BLOCK_OVERHEAD;
175175 }
176176
177- // / @returns The number of usable bytes inside the block were it to be
178- // / allocated.
177+ // / @returns The number of usable bytes inside the block.
179178 size_t inner_size () const {
180179 if (!next ())
181180 return 0 ;
182181 return inner_size (outer_size ());
183182 }
184183
185- // / @returns The number of usable bytes inside a block with the given outer
186- // / size were it to be allocated.
187184 static size_t inner_size (size_t outer_size) {
188185 // The usable region includes the prev_ field of the next block.
189- return inner_size_free (outer_size) + sizeof (prev_);
190- }
191-
192- // / @returns The number of usable bytes inside the block if it remains free.
193- size_t inner_size_free () const {
194- if (!next ())
195- return 0 ;
196- return inner_size_free (outer_size ());
197- }
198-
199- // / @returns The number of usable bytes inside a block with the given outer
200- // / size if it remains free.
201- static size_t inner_size_free (size_t outer_size) {
202- return outer_size - BLOCK_OVERHEAD;
186+ return outer_size - BLOCK_OVERHEAD + sizeof (prev_);
203187 }
204188
205189 // / @returns A pointer to the usable space inside this block.
@@ -217,11 +201,14 @@ class Block {
217201
218202 // / Attempts to split this block.
219203 // /
220- // / If successful, the block will have an inner size of at least
221- // / `new_inner_size`, rounded to ensure that the split point is on an
222- // / ALIGNMENT boundary. The remaining space will be returned as a new block.
223- // / Note that the prev_ field of the next block counts as part of the inner
224- // / size of the returnd block.
204+ // / If successful, the block will have an inner size of `new_inner_size`,
205+ // / rounded to ensure that the split point is on an ALIGNMENT boundary. The
206+ // / remaining space will be returned as a new block. Note that the prev_ field
207+ // / of the next block counts as part of the inner size of the returnd block.
208+ // /
209+ // / This method may fail if the remaining space is too small to hold a new
210+ // / block. If this method fails for any reason, the original block is
211+ // / unmodified.
225212 optional<Block *> split (size_t new_inner_size);
226213
227214 // / Merges this block with the one that comes after it.
@@ -455,7 +442,7 @@ Block<OffsetType, kAlign>::split(size_t new_inner_size) {
455442 // The prev_ field of the next block is always available, so there is a
456443 // minimum size to a block created through splitting.
457444 if (new_inner_size < sizeof (prev_))
458- new_inner_size = sizeof (prev_) ;
445+ return {} ;
459446
460447 size_t old_inner_size = inner_size ();
461448 new_inner_size =
0 commit comments