![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0-only 0002 /* 0003 * A generic implementation of binary search for the Linux kernel 0004 * 0005 * Copyright (C) 2008-2009 Ksplice, Inc. 0006 * Author: Tim Abbott <tabbott@ksplice.com> 0007 */ 0008 0009 #include <linux/export.h> 0010 #include <linux/bsearch.h> 0011 #include <linux/kprobes.h> 0012 0013 /* 0014 * bsearch - binary search an array of elements 0015 * @key: pointer to item being searched for 0016 * @base: pointer to first element to search 0017 * @num: number of elements 0018 * @size: size of each element 0019 * @cmp: pointer to comparison function 0020 * 0021 * This function does a binary search on the given array. The 0022 * contents of the array should already be in ascending sorted order 0023 * under the provided comparison function. 0024 * 0025 * Note that the key need not have the same type as the elements in 0026 * the array, e.g. key could be a string and the comparison function 0027 * could compare the string with the struct's name field. However, if 0028 * the key and elements in the array are of the same type, you can use 0029 * the same comparison function for both sort() and bsearch(). 0030 */ 0031 void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp) 0032 { 0033 return __inline_bsearch(key, base, num, size, cmp); 0034 } 0035 EXPORT_SYMBOL(bsearch); 0036 NOKPROBE_SYMBOL(bsearch);
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |