Skip to content

Instantly share code, notes, and snippets.

@richo
Created January 25, 2013 00:39
Show Gist options
  • Save richo/4630407 to your computer and use it in GitHub Desktop.
Save richo/4630407 to your computer and use it in GitHub Desktop.
signed
WS_Reserve(struct ws *ws, unsigned bytes)
{
unsigned b2;
WS_Assert(ws);
assert(ws->r == NULL);
if (bytes == 0)
b2 = ws->e - ws->f;
else if (bytes > ws->e - ws->f)
b2 = ws->e - ws->f;
else
b2 = bytes;
b2 = PRNDDN(b2);
xxxassert(ws->f + b2 <= ws->e);
ws->r = ws->f + b2;
DSL(DBG_WORKSPACE, 0, "WS_Reserve(%p, %u/%u) = %u",
ws, b2, bytes, pdiff(ws->f, ws->r));
WS_Assert(ws);
return (pdiff(ws->f, ws->r));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment