From a684f95cbcee7f2568a2ce04e7dc2bbb605a27b3 Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Thu, 15 May 2008 21:51:22 +0000 Subject: Incremental reduce first checkin. Warning! Disk format change. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@656861 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_util.erl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/couchdb/couch_util.erl') diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index 0c51f39b..81234c2b 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -16,7 +16,7 @@ -export([parse_ini/1,should_flush/0, should_flush/1]). -export([new_uuid/0, rand32/0, implode/2, collate/2, collate/3]). -export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]). --export([encodeBase64/1, decodeBase64/1]). +-export([encodeBase64/1, decodeBase64/1, to_hex/1]). % arbitrarily chosen amount of memory to use before flushing to disk @@ -30,20 +30,21 @@ start_driver(LibDir) -> {error, already_loaded} -> ok; Error -> exit(Error) end. - - + + + new_uuid() -> - to_hex(binary_to_list(crypto:rand_bytes(16))). - + to_hex(crypto:rand_bytes(16)). + to_hex([]) -> []; +to_hex(Bin) when is_binary(Bin) -> + to_hex(binary_to_list(Bin)); to_hex([H|T]) -> [to_digit(H div 16), to_digit(H rem 16) | to_hex(T)]. -to_digit(N) when N < 10 -> - $0 + N; -to_digit(N) -> - $a + N-10. +to_digit(N) when N < 10 -> $0 + N; +to_digit(N) -> $a + N-10. % returns a random integer -- cgit v1.2.3