<div>This then also breaks the previous expectation that cur_seg would</div><div>always be non-NULL. Change the code to take this into account.</div><div><br></div><div>Review comments:</div><div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+       ALLOC_OBJ(sg, SMP_SEG_MAGIC);<br>+       AN(sg);<br>Instead of AN, you should just return failure.  We should handle<br>malloc failures gracefully where we can easily do so.</blockquote><div><br></div><div>Returning failure in this case now.</div>

<div><br></div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

In both the next two cases, you should consider truncation<br>of the new segment, it's silly to waste a full segment if<br>the overflow is just one page:</blockquote></div><div><br></div><div>Added XXX-comments on truncation suggestion.</div>

<div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

For clarity, always keep left in sync with cur_seg:</blockquote><div><br></div><div>Done </div></div><div><br></div>-- <br>Martin Blix Grydeland<br>Varnish Software AS<br><br>