glue.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright (c) 2024 Bruce A Henderson
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. 1. Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. 2. Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  11. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  13. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  14. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  16. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  17. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  18. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  19. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. */
  21. #include "brl.mod/blitz.mod/hash/xxhash.h"
  22. #include "brl.mod/blitz.mod/blitz.h"
  23. XXH3_state_t * bmx_digest_xxh3_init() {
  24. XXH3_state_t* state = XXH3_createState();
  25. XXH3_64bits_reset(state);
  26. return state;
  27. }
  28. void bmx_digest_xxh3_free(XXH3_state_t * state) {
  29. XXH3_freeState(state);
  30. }
  31. void bmx_digest_xxh3_update(XXH3_state_t * state, char * buf, int length) {
  32. XXH3_64bits_update(state, buf, length);
  33. }
  34. void bmx_digest_xxh3_finish(XXH3_state_t * state, char * out, int size) {
  35. XXH64_hash_t hash = XXH3_64bits_digest(state);
  36. memcpy(out, &hash, size);
  37. XXH3_64bits_reset(state); // reset state
  38. }
  39. void bmx_digest_xxh3_finish_ulong(XXH3_state_t * state, BBULONG * out) {
  40. XXH64_hash_t hash = XXH3_64bits_digest(state);
  41. *out = hash;
  42. XXH3_64bits_reset(state); // reset state
  43. }
  44. void bmx_digest_xxh3_reset(XXH3_state_t * state) {
  45. XXH3_64bits_reset(state);
  46. }