Skip to content

Instantly share code, notes, and snippets.

@bricef
Created April 21, 2012 18:13
Show Gist options
  • Save bricef/2438900 to your computer and use it in GitHub Desktop.
Save bricef/2438900 to your computer and use it in GitHub Desktop.
Pad a byte[] to a given block size
void* padBuffer(void* buf, int buflen, int blocklen){
void* barr;
int barrlen;
if(buflen > blocklen){
barrlen = buflen + (blocklen-(buflen%blocklen));
}else{
barrlen = blocklen;
}
barr = calloc(1, barrlen);
memcpy(barr, buf, buflen);
return barr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment