Created
April 21, 2012 18:13
-
-
Save bricef/2438900 to your computer and use it in GitHub Desktop.
Pad a byte[] to a given block size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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