utmm.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. /*
  5. Copyright (c) 2003-2015, Troy D. Hanson http://troydhanson.github.com/uthash/
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright
  10. notice, this list of conditions and the following disclaimer.
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  12. IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  13. TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  14. PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  15. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  16. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  20. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. /* utmm
  24. *
  25. * low level memory primitives
  26. *
  27. */
  28. #ifndef __UTMM_H_
  29. #define __UTMM_H_
  30. typedef struct {
  31. size_t sz;
  32. void (*init)(void *buf); //-> utstring-init
  33. void (*fini)(void *buf); //-> utstring-done
  34. void (*copy)(void *dst, void *src); //-> ustring_concat
  35. void (*clear)(void *buf); //-> utstring-clear
  36. } UT_mm;
  37. void *utmm_new(const UT_mm *mm, size_t n);
  38. void utmm_init(const UT_mm *mm, void *buf, size_t n);
  39. void utmm_fini(const UT_mm *mm, void *buf, size_t n);
  40. void utmm_clear(const UT_mm *mm, void *buf, size_t n);
  41. void utmm_copy(const UT_mm *mm, void *dst, void *src, size_t n);
  42. /* convenient predefined mm */
  43. extern UT_mm* utmm_int;
  44. extern UT_mm* utstring_mm;
  45. #endif /* __UTMM_H_ */