~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSStorage.cc

  • Committer: Lee Bieber
  • Date: 2010-10-22 16:47:38 UTC
  • mfrom: (1841.1.7 drizzle_pbms)
  • Revision ID: kalebral@gmail.com-20101022164738-vv8w22b8towpb307
Merge Barry - fix bug 657830: PBMS build failure in GCC 4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
void CSHashTable::setSize(uint32_t size)
56
56
{
57
57
        enter_();
58
 
        cs_realloc((void **) &iTable, sizeof(CSObject *) * size);
 
58
        if (size == 0) {
 
59
                if (iTable) {
 
60
                        cs_free(iTable);
 
61
                        iTable = NULL;
 
62
                }
 
63
        }
 
64
        else {
 
65
                cs_realloc((void **) &iTable, sizeof(CSObject *) * size);
 
66
                memset(iTable, 0, sizeof(CSObject *) * size);
 
67
        }
59
68
        iSize = size;
60
69
        exit_();
61
70
}
83
92
        return NULL;
84
93
}
85
94
 
86
 
void CSHashTable::remove(CSObject *key)
 
95
bool CSHashTable::remove(CSObject *key)
87
96
{
88
97
        uint32_t h = key->hashKey();
89
98
        CSObject *item, *prev_item;
98
107
                        else
99
108
                                iTable[h % iSize] = item->getHashLink();
100
109
                        item->release();
101
 
                        break;
 
110
                        return true;
102
111
                }
103
112
                prev_item = item;
104
113
                item = item->getHashLink();
105
114
        }
 
115
        return false;
106
116
}
107
117
 
108
118
void CSHashTable::clear()
182
192
                
183
193
        item =  iList[idx];
184
194
        
 
195
        iInUse--;
185
196
        memmove(&iList[idx], &iList[idx+1], (iInUse - idx) * sizeof(CSObject *));
186
 
        iInUse--;
187
197
        return item;
188
198
}
189
199
 
193
203
        uint32_t                idx;
194
204
 
195
205
        if ((item = search(key, idx))) {
 
206
                iInUse--;
196
207
                memmove(&iList[idx], &iList[idx+1], (iInUse - idx) * sizeof(CSObject *));
197
 
                iInUse--;
198
208
                item->release();
199
209
        }
200
210
}
263
273
                item->release();
264
274
}
265
275
 
 
276
void CSLinkedList::addBack(CSObject *item)
 
277
{
 
278
        if (iListBack != item) {
 
279
                remove(item);
 
280
                item->setNextLink(iListBack);
 
281
                item->setPrevLink(NULL);
 
282
                
 
283
                if (iListBack)
 
284
                        iListBack->setPrevLink(item);
 
285
                else
 
286
                        iListFront = item;
 
287
                iListBack = item;
 
288
                iSize++;
 
289
        }
 
290
        else
 
291
                /* Must do this or I will have one reference too
 
292
                 * many!
 
293
                 * The input object was given to me referenced,
 
294
                 * but I already have the object on my list, and
 
295
                 * referenced!
 
296
                 */
 
297
                item->release();
 
298
}
 
299
 
266
300
bool CSLinkedList::remove(CSObject *item)
267
301
{
268
302
        bool on_list = false;
505
539
{
506
540
        uint32_t pos;
507
541
 
 
542
        // If search fails then pos will be > iUsage
508
543
        search(idx, pos);
509
544
        return pos;
510
545
}
655
690
                CSOrderedListItemRec ir;
656
691
 
657
692
                memcpy(&ir, item, sizeof(CSOrderedListItemRec));
 
693
                iInUse--;
658
694
                memmove(&iList[idx], &iList[idx+1], (iInUse - idx) * sizeof(CSOrderedListItemRec));
659
 
                iInUse--;
660
695
                if (ir.li_key)
661
696
                        ir.li_key->release();
662
697
                if (ir.li_item)