You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
493B

  1. /*
  2. * This file is a part of SMalloc.
  3. * SMalloc is MIT licensed.
  4. * Copyright (c) 2017 Andrey Rys.
  5. */
  6. #include "smalloc_i.h"
  7. int sm_alloc_valid_pool(struct smalloc_pool *spool, const void *p)
  8. {
  9. struct smalloc_hdr *shdr;
  10. if (!smalloc_verify_pool(spool)) {
  11. errno = EINVAL;
  12. return 0;
  13. }
  14. if (!p) return 0;
  15. shdr = USER_TO_HEADER(p);
  16. if (smalloc_is_alloc(spool, shdr)) return 1;
  17. return 0;
  18. }
  19. int sm_alloc_valid(const void *p)
  20. {
  21. return sm_alloc_valid_pool(&smalloc_curr_pool, p);
  22. }