1 /* 2 * Copyright 2011 Joakim Sindholt <[email protected]> 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #ifndef _NINE_PDATA_H_ 7 #define _NINE_PDATA_H_ 8 9 #include "util/hash_table.h" 10 11 struct pheader 12 { 13 bool unknown; 14 GUID guid; 15 DWORD size; 16 }; 17 18 static bool ht_guid_compare(const void * a,const void * b)19ht_guid_compare( const void *a, 20 const void *b ) 21 { 22 return GUID_equal(a, b); 23 } 24 25 static uint32_t ht_guid_hash(const void * key)26ht_guid_hash( const void *key ) 27 { 28 unsigned i, hash = 0; 29 const unsigned char *str = key; 30 31 for (i = 0; i < sizeof(GUID); i++) { 32 hash = (unsigned)(str[i]) + (hash << 6) + (hash << 16) - hash; 33 } 34 35 return hash; 36 } 37 38 static void ht_guid_delete(struct hash_entry * entry)39ht_guid_delete( struct hash_entry *entry ) 40 { 41 struct pheader *header = entry->data; 42 void *header_data = (void *)header + sizeof(*header); 43 44 if (header->unknown) { IUnknown_Release(*(IUnknown **)header_data); } 45 FREE(header); 46 } 47 48 #endif /* _NINE_PDATA_H_ */ 49