# Path: haystack/listmodel.py
# class ListModel(basicmodel.CTypesRecordConstraintValidator):
#     def is_single_linked_list_type(self, record_type):
#     def is_double_linked_list_type(self, record_type):
#     def get_single_linked_list_type(self, record_type):
#     def get_double_linked_list_type(self, record_type):
#     def register_single_linked_list_record_type(self, record_type, forward, sentinels=None):
#     def register_double_linked_list_record_type(self, record_type, forward, backward, sentinels=None):
#     def register_linked_list_field_and_type(self, record_type, field_name, list_entry_type, list_entry_field_name):
#     def _get_list_info_for_field_for(self, record_type, fieldname):
#     def _get_list_fields(self, record_type):
#     def iterate_list_from_field(self, record, fieldname, sentinels=None, ignore_head=True):
#     def iterate_list_from_pointer_field(self, pointer_field, target_fieldname, sentinels=None):
#     def _iterate_list_from_field_with_link_info(self, record, link_info, sentinels=None, ignore_head=True):
#     def _iterate_list_from_field_inner(self, iterator_fn, head, pointee_record_type, offset, sentinels):
#     def _iterate_double_linked_list(self, record, sentinels=None):
#     def _iterate_single_linked_list(self, record, sentinels=None):
#     def is_valid(self, record):
#     def load_members(self, record, max_depth):
#     def _load_list_entries(self, record, link_iterator, max_depth):


import ctypes
import logging
import sys
from haystack import listmodel
    try:
        # i'm lazy. Heap validation could be 10 chunks deep.
        # but we validate _is_heap by looking at the mapping size
        sizes = [
            size for (
                addr,
                size) in validator.iter_user_allocations(
                mapping)]
        size = sum(sizes)
    except ValueError as e:
        log.debug(e)
        return False
    except NotImplementedError as e:
        # file absent
        log.debug(e)
        return False
    # FIXME: is malloc word size dependent
    if size != (len(mapping) - target_platform.get_word_size() * len(sizes)):
        log.debug(
            'expected %d/%d bytes, got %d' %
            (len(mapping),
             len(mapping) -
                2 *
                target_platform.get_word_size() *
                len(sizes),
                size))
        return False
    return True



# Path: haystack/listmodel.py
# class ListModel(basicmodel.CTypesRecordConstraintValidator):
#     def is_single_linked_list_type(self, record_type):
#     def is_double_linked_list_type(self, record_type):
#     def get_single_linked_list_type(self, record_type):
#     def get_double_linked_list_type(self, record_type):
#     def register_single_linked_list_record_type(self, record_type, forward, sentinels=None):
#     def register_double_linked_list_record_type(self, record_type, forward, backward, sentinels=None):
#     def register_linked_list_field_and_type(self, record_type, field_name, list_entry_type, list_entry_field_name):
#     def _get_list_info_for_field_for(self, record_type, fieldname):
#     def _get_list_fields(self, record_type):
#     def iterate_list_from_field(self, record, fieldname, sentinels=None, ignore_head=True):
#     def iterate_list_from_pointer_field(self, pointer_field, target_fieldname, sentinels=None):
#     def _iterate_list_from_field_with_link_info(self, record, link_info, sentinels=None, ignore_head=True):
#     def _iterate_list_from_field_inner(self, iterator_fn, head, pointee_record_type, offset, sentinels):
#     def _iterate_double_linked_list(self, record, sentinels=None):
#     def _iterate_single_linked_list(self, record, sentinels=None):
#     def is_valid(self, record):
#     def load_members(self, record, max_depth):
#     def _load_list_entries(self, record, link_iterator, max_depth):


# Path: haystack/allocators/libc/ctypes_malloc.py
import ctypes
import logging
import sys
from haystack import listmodel

    try:
        # i'm lazy. Heap validation could be 10 chunks deep.
        # but we validate _is_heap by looking at the mapping size
        sizes = [
            size for (
                addr,
                size) in validator.iter_user_allocations(
                mapping)]
        size = sum(sizes)
    except ValueError as e:
        log.debug(e)
        return False
    except NotImplementedError as e:
        # file absent
        log.debug(e)
        return False
    # FIXME: is malloc word size dependent
    if size != (len(mapping) - target_platform.get_word_size() * len(sizes)):
        log.debug(
            'expected %d/%d bytes, got %d' %
            (len(mapping),
             len(mapping) -
                2 *
                target_platform.get_word_size() *
                len(sizes),
                size))
        return False
    return True



class LibcHeapValidator(listmodel.ListModel):