2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "TableCallbacks.h"
25 //#define NSNonOwnedCStringMapKeyCallBacks NSNonOwnedPointerMapKeyCallBacks
27 /* From Aho, Sethi & Ullman: Principles of compiler design. */
28 static unsigned __hashCString(void *table, const void *aString) {
29 register const char* p = (char*)aString;
30 register unsigned hash = 0, hash2;
33 n = aString ? strlen(aString) : 0;
34 for(i=0; i < n; i++) {
37 if((hash2 = hash & 0xf0000000))
38 hash ^= (hash2 >> 24) ^ hash2;
43 static BOOL __compareCString(void *table,
44 const void *anObject1,
45 const void *anObject2)
47 if (anObject1 == NULL && anObject2 == NULL) return YES;
48 if (anObject1 == NULL || anObject2 == NULL) return NO;
49 return strcmp((char*)anObject1, (char*)anObject2) == 0;
52 static void __retain(void *table, const void *anObject) {}
53 static void __release(void *table, void *anObject) {}
55 static NSString *__describe(void *table, const void *anObject) {
56 return [NSString stringWithFormat:@"%p", anObject];
59 const NSMapTableKeyCallBacks libxmlNonOwnedCStringMapKeyCallBacks = {
60 (unsigned(*)(NSMapTable *, const void *))__hashCString,
61 (BOOL(*)(NSMapTable *, const void *, const void *))__compareCString,
62 (void (*)(NSMapTable *, const void *anObject))__retain,
63 (void (*)(NSMapTable *, void *anObject))__release,
64 (NSString *(*)(NSMapTable *, const void *))__describe,