Added calc_padding() convenience function for calculating how much padding to add to a buffer in order for it to fall on a specified byte boundary.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8889 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz 2004-09-07 23:06:32 +00:00
parent e4265bfbfe
commit 02043d35db
2 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,8 @@ status_t entry_ref_flatten(char* buffer, size_t* size, const entry_ref* ref);
status_t entry_ref_unflatten(entry_ref* ref, const char* buffer, size_t size);
status_t entry_ref_swap(char* buffer, size_t size);
size_t calc_padding(size_t size, size_t boundary);
} // namespace BPrivate
//------------------------------------------------------------------------------

View File

@ -138,6 +138,16 @@ status_t entry_ref_swap(char* buffer, size_t size)
return B_OK;
}
//------------------------------------------------------------------------------
size_t calc_padding(size_t size, size_t boundary)
{
size_t pad = size % boundary;
if (pad)
{
pad = boundary - pad;
}
return pad;
}
//------------------------------------------------------------------------------
} // namespace BPrivate