diff options
author | lloyd <[email protected]> | 2008-11-23 18:13:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-23 18:13:40 +0000 |
commit | 36c4e419e899f650d32712594fc947f9f7960992 (patch) | |
tree | 9ed556e3acb55c935f7ba6e78960128355bac71e /src/utils/xor_buf.h | |
parent | 1bddfc5aeffc8ece20c18b4b8f6a9a006969ff80 (diff) |
Move xor_into_buf to xor_buf.cpp. Also add a new template wrapper for
xoring integer values in.
Diffstat (limited to 'src/utils/xor_buf.h')
-rw-r--r-- | src/utils/xor_buf.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/utils/xor_buf.h b/src/utils/xor_buf.h index 975ad0af6..bbc6d3eec 100644 --- a/src/utils/xor_buf.h +++ b/src/utils/xor_buf.h @@ -68,18 +68,19 @@ inline void xor_buf(byte out[], } /** -* Xor values into buffer +* XOR values into buffer. Might do RLE on input */ -inline u32bit xor_into_buf(byte buf[], u32bit buf_i, u32bit length, - const void* in_void, u32bit in_len) +u32bit xor_into_buf(byte buf[], u32bit buf_i, u32bit length, + const void* in_void, u32bit in_len); + +/** +* XOR integer value (or something else, I guess) into buffer +*/ +template<typename T> +u32bit xor_into_buf(byte buf[], u32bit buf_i, + u32bit length, T in) { - const byte* in = static_cast<const byte*>(in_void); - for(u32bit i = 0; i != in_len; ++i) - { - buf[buf_i] ^= in[i]; - buf_i = (buf_i + 1) % length; - } - return buf_i; + return xor_into_buf(buf, buf_i, length, &in, sizeof(in)); } } |