Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

41 lines
1.1KB

  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. struct smalloc_hdr {
  13. size_t rsz; /* real allocated size with overhead (if any) */
  14. size_t usz; /* exact user size as reported by s_szalloc */
  15. uintptr_t tag; /* sum of all the above, hashed value */
  16. };
  17. #define HEADER_SZ (sizeof(struct smalloc_hdr))
  18. #define MIN_POOL_SZ (HEADER_SZ*20)
  19. #define VOID_PTR(p) ((void *)p)
  20. #define CHAR_PTR(p) ((char *)p)
  21. #define PTR_UINT(p) ((uintptr_t)VOID_PTR(p))
  22. #define HEADER_PTR(p) ((struct smalloc_hdr *)p)
  23. #define USER_TO_HEADER(p) (HEADER_PTR((CHAR_PTR(p)-HEADER_SZ)))
  24. #define HEADER_TO_USER(p) (VOID_PTR((CHAR_PTR(p)+HEADER_SZ)))
  25. extern smalloc_ub_handler smalloc_UB;
  26. uintptr_t smalloc_uinthash(uintptr_t x);
  27. uintptr_t smalloc_mktag(struct smalloc_hdr *shdr);
  28. int smalloc_verify_pool(struct smalloc_pool *spool);
  29. int smalloc_is_alloc(struct smalloc_pool *spool, struct smalloc_hdr *shdr);
  30. void *sm_realloc_pool_i(struct smalloc_pool *spool, void *p, size_t n, int nomove);
  31. #endif