1
/* Copyright (c) 2005 PrimeBase Technologies GmbH
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.
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.
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
19
* 2006-05-16 Paul McCullagh
26
#include "xt_config.h"
28
#include "pthread_xt.h"
29
#include "ccutils_xt.h"
30
#include "bsearch_xt.h"
32
static int ccu_compare_object(XTThreadPtr XT_UNUSED(self), register const void *XT_UNUSED(thunk), register const void *a, register const void *b)
34
XTObject *obj_ptr = (XTObject *) b;
36
return obj_ptr->compare(a);
39
void XTListImp::append(XTThreadPtr self, XTObject *info, void *key) {
42
if (li_item_count == 0)
44
else if (li_item_count == 1) {
47
if ((r = li_items[0]->compare(key)) == 0)
55
xt_bsearch(self, key, li_items, li_item_count, sizeof(void *), &idx, NULL, ccu_compare_object);
58
if (!xt_realloc(NULL, (void **) &li_items, (li_item_count + 1) * sizeof(void *))) {
61
xt_throw_errno(XT_CONTEXT, XT_ENOMEM);
64
memmove(&li_items[idx+1], &li_items[idx], (li_item_count-idx) * sizeof(void *));