char *temp = malloc(sizeof(uint32_t) + hm->unitSize);
memcpy(temp, &key, sizeof(uint32_t));
- memcpy(temp + sizeof(uint32_t), data, hm->unitSize);
+ if(hm->unitSize > 0)
+ {
+ memcpy(temp + sizeof(uint32_t), data, hm->unitSize);
+ }
if(UDPC_Deque_get_available(hm->buckets[hash]) != 0)
{
&key,
sizeof(uint32_t)) == 0)
{
- return ptr + sizeof(uint32_t);
+ if(hm->unitSize > 0)
+ {
+ return ptr + sizeof(uint32_t);
+ }
+ else
+ {
+ return ptr;
+ }
}
}
&key,
sizeof(uint32_t)) == 0)
{
- return ptr + sizeof(uint32_t);
+ if(hm->unitSize > 0)
+ {
+ return ptr + sizeof(uint32_t);
+ }
+ else
+ {
+ return ptr;
+ }
}
}
/*!
* \brief Returns a pointer to data with the given key
+ * Note if unitSize == 0, then the returned pointer will point to a copy of
+ * its integer key, which should not be changed manually (otherwise, the hash
+ * map would not be able to find it).
* \return non-NULL if data was found
*/
void* UDPC_HashMap_get(UDPC_HashMap *hm, uint32_t key);