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:
parent
e4265bfbfe
commit
02043d35db
@ -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
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user