summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/base64.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-06 23:02:52 +0100
committerDan McGee <dan@archlinux.org>2012-01-07 18:27:41 +0100
commitd59324c8fff0a91930bf226d013273691f0580e6 (patch)
treea357aae15d3e0e9d4a9f710edce18d6b3ed27c70 /lib/libalpm/base64.c
parent6513b0ba591e44b4da75aa924046a34b8a269e9d (diff)
downloadpacman-d59324c8fff0a91930bf226d013273691f0580e6.tar.gz
pacman-d59324c8fff0a91930bf226d013273691f0580e6.tar.xz
Use 32-bit wide integer type in PolarSSL code
A look at what this does on 64 bit systems since we were using the unnecessarily large 'unsigned long' type before even though it was 64 bits wide: $ ~/bin/bloat-o-meter libalpm.so.old lib/libalpm/.libs/libalpm.so add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-10412 (-10412) function old new delta md5_finish 370 356 -14 sha2_finish 547 531 -16 md5_process 3762 2643 -1119 sha2_process 20356 11093 -9263 The code size is nearly halved in the sha2 case (44% smaller code size), and md5 gets a nice size reduction (27% smaller) as well. We also move base64 code to <stdint.h> types as well; we can use 'uint32_t' rather than 'unsigned long' for at least two variables in the decode function. This doesn't net the same size benefit as the hash code case, but it is more proper. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/base64.c')
-rw-r--r--lib/libalpm/base64.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libalpm/base64.c b/lib/libalpm/base64.c
index 0d29f656..32c44459 100644
--- a/lib/libalpm/base64.c
+++ b/lib/libalpm/base64.c
@@ -32,6 +32,8 @@
* * removal of SELF_TEST code
*/
+#include <stdint.h>
+
#include "base64.h"
static const unsigned char base64_enc_map[64] =
@@ -133,8 +135,8 @@ int base64_encode( unsigned char *dst, size_t *dlen,
int base64_decode( unsigned char *dst, size_t *dlen,
const unsigned char *src, size_t slen )
{
- size_t i, j, n;
- unsigned long x;
+ size_t i, n;
+ uint32_t j, x;
unsigned char *p;
for( i = j = n = 0; i < slen; i++ )