~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to storage/pbxt/src/bsearch_xt.cc

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2005 PrimeBase Technologies GmbH
2
 
 *
3
 
 * PrimeBase XT
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
 
 *
19
 
 * 2004-01-03   Paul McCullagh
20
 
 *
21
 
 * H&G2JCtL
22
 
 */
23
 
 
24
 
#include "xt_config.h"
25
 
 
26
 
#include <stdio.h>
27
 
 
28
 
#include "bsearch_xt.h"
29
 
#include "pthread_xt.h"
30
 
#include "thread_xt.h"
31
 
 
32
 
/**
33
 
 * Binary search a array of 'count' items, with byte size 'size'. This
34
 
 * function returns a pointer to the element and the 'index'
35
 
 * of the element if found.
36
 
 *
37
 
 * If not found the index of the insert point of the item
38
 
 * is returned (0 <= index <= count).
39
 
 *
40
 
 * The comparison routine 'compar' may throw an exception.
41
 
 * In this case the error details will be stored in 'thread'.
42
 
 */
43
 
void *xt_bsearch(XTThreadPtr thread, const void *key, register const void *base, size_t count, size_t size, size_t *idx, const void *thunk, XTCompareFunc compar)
44
 
{
45
 
        register size_t         i;
46
 
        register size_t         guess;
47
 
        register int            r;
48
 
 
49
 
        i = 0;
50
 
        while (i < count) {
51
 
                guess = (i + count - 1) >> 1;
52
 
                r = (compar)(thread, thunk, key, ((char *) base) + guess * size);
53
 
                if (r == 0) {
54
 
                        *idx = guess;
55
 
                        return ((char *) base) + guess * size;
56
 
                }
57
 
                if (r < 0)
58
 
                        count = guess;
59
 
                else
60
 
                        i = guess + 1;
61
 
        }
62
 
 
63
 
        *idx = i;
64
 
        return NULL;
65
 
}
66