X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/22b9fa74de8e80471a5033ea067d3b360930b91d..0e2b222fc14b8f890fab644118cf0f43abbe450a:/lib/basen.c diff --git a/lib/basen.c b/lib/basen.c index c5644b4..74cb836 100644 --- a/lib/basen.c +++ b/lib/basen.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2005 Richard Kettlewell + * Copyright (C) 2005, 2007, 2008 Richard Kettlewell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,7 +72,7 @@ static unsigned divide(unsigned long *v, int nwords, unsigned long m) { } /** @brief Convert v to a chosen base - * @param v Pointer to bigendian bignum + * @param v Pointer to bigendian bignum (modified!) * @param nwords Length of bignum * @param buffer Output buffer * @param bufsize Size of output buffer @@ -91,7 +91,8 @@ int basen(unsigned long *v, static const char chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; do { - if(i <= 1) return -1; /* overflow */ + if(i <= 1) + return -1; /* overflow */ buffer[--i] = chars[divide(v, nwords, base)]; } while(!zero(v, nwords)); memmove(buffer, buffer + i, bufsize - i);