選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

49 行
1.2KB

  1. /*
  2. * This file is a part of SMalloc.
  3. * SMalloc is MIT licensed.
  4. * Copyright (c) 2017 Andrey Rys.
  5. */
  6. #ifndef _SMALLOC_I_H
  7. #define _SMALLOC_I_H
  8. #include "smalloc.h"
  9. #include <string.h>
  10. #include <limits.h>
  11. #include <errno.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. struct smalloc_hdr {
  16. size_t rsz; /* real allocated size with overhead (if any) */
  17. size_t usz; /* exact user size as reported by s_szalloc */
  18. uintptr_t tag; /* sum of all the above, hashed value */
  19. };
  20. #define HEADER_SZ (sizeof(struct smalloc_hdr))
  21. #define MIN_POOL_SZ (HEADER_SZ*20)
  22. #define VOID_PTR(p) ((void *)p)
  23. #define CHAR_PTR(p) ((char *)p)
  24. #define PTR_UINT(p) ((uintptr_t)VOID_PTR(p))
  25. #define HEADER_PTR(p) ((struct smalloc_hdr *)p)
  26. #define USER_TO_HEADER(p) (HEADER_PTR((CHAR_PTR(p)-HEADER_SZ)))
  27. #define HEADER_TO_USER(p) (VOID_PTR((CHAR_PTR(p)+HEADER_SZ)))
  28. extern smalloc_ub_handler smalloc_UB;
  29. uintptr_t smalloc_uinthash(uintptr_t x);
  30. uintptr_t smalloc_mktag(struct smalloc_hdr *shdr);
  31. int smalloc_verify_pool(struct smalloc_pool *spool);
  32. int smalloc_is_alloc(struct smalloc_pool *spool, struct smalloc_hdr *shdr);
  33. void *sm_realloc_pool_i(struct smalloc_pool *spool, void *p, size_t n, int nomove);
  34. #ifdef __cplusplus
  35. } // extern "C"
  36. #endif
  37. #endif