/* * Copyright 2011 Institute of Communication and Computer Systems (ICCS) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * \file search_algorithms.h * \author Ioannis Koutras (joko@microlab.ntua.gr) * \date September, 2011 * * \brief Various search algorithms for linked list structures used on DMMLib. */ #ifndef LINKED_LISTS_SEARCH_ALGORITHMS_H #define LINKED_LISTS_SEARCH_ALGORITHMS_H #include #include #ifdef WITH_FIXED_LISTS /** * Perform an exact-fit search on fixed lists for a block of a certain size * * \param heap The heap whose fixed lists should be accessed. * \param requested_size The desired size of the block. * * \return The pointer of the data part of the matched memory block. * \retval NULL No block was found. */ void * search_on_fixed(heap_t * heap, size_t requested_size); #endif /* WITH_FIXED_LISTS */ /** * Perform a best-fit search on free lists for a block of a certain size * * \param heap The heap whose fixed lists should be accessed. * \param requested_size The desired size of the block. * * \return The pointer of the data part of the matched memory block. * \retval NULL No block was found. */ void * best_fit_on_freelist(heap_t *heap, size_t requested_size); /** * Perform a good-fit search on the free list * * \param heap The heap whose free list should be accessed. * \param requested_size The desired size of the block. * \param fit_percentage The lowest acceptable percentage of the block space to be filled. * * \return The pointer to the data part of the matched memory block. * \retval NULL No block was found. */ void * good_fit_on_freelist(heap_t *heap, size_t requested_size, float fit_percentage); /** * Perform an exact-fit search on free lists for a block of a certain size * * \param heap The heap whose fixed lists should be accessed. * \param requested_size The desired size of the block. * * \return The pointer of the data part of the matched memory block. * \retval NULL No block was found. */ void * exact_fit_on_freelist(heap_t *heap, size_t requested_size); /** * Perform a first-fit search on free lists for a block of a certain size * * \param heap The heap whose fixed lists should be accessed. * \param requested_size The desired size of the block. * * \return The pointer of the data part of the matched memory block. * \retval NULL No block was found. */ void * first_fit_on_freelist(heap_t *heap, size_t requested_size); #endif /* LINKED_LISTS_SEARCH_ALGORITHMS_H */