# 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Loic Jaquemet loic.jaquemet+python@gmail.com
#

__author__ = "Loic Jaquemet loic.jaquemet+python@gmail.com"



log = logging.getLogger('ctypes_malloc')


# SIZE_SZ = Config.WORDSIZE
# MIN_CHUNK_SIZE        = 4 * SIZE_SZ
# MALLOC_ALIGNMENT    = 2 * SIZE_SZ
# MALLOC_ALIGN_MASK = MALLOC_ALIGNMENT - 1
# MINSIZE                     = (MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK

PREV_INUSE = 1
IS_MMAPPED = 2
NON_MAIN_ARENA = 4
SIZE_BITS = (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA)





# 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

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Loic Jaquemet loic.jaquemet+python@gmail.com
#

__author__ = "Loic Jaquemet loic.jaquemet+python@gmail.com"



log = logging.getLogger('ctypes_malloc')


# SIZE_SZ = Config.WORDSIZE
# MIN_CHUNK_SIZE        = 4 * SIZE_SZ
# MALLOC_ALIGNMENT    = 2 * SIZE_SZ
# MALLOC_ALIGN_MASK = MALLOC_ALIGNMENT - 1
# MINSIZE                     = (MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK

PREV_INUSE = 1
IS_MMAPPED = 2
NON_MAIN_ARENA = 4
SIZE_BITS = (PREV_INUSE | IS_MMAPPED | NON_MAIN_ARENA)





def is_malloc_heap(memory_handler, mapping):