summaryrefslogtreecommitdiff
path: root/src/tag
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-07 23:12:24 +0100
committerMax Kellermann <max@duempel.org>2014-01-07 23:12:24 +0100
commit8a30c7992dd59f9a742969dceaad0a71ae2ed296 (patch)
tree92006a3ec3bc5dd82b0c1275cd95a1af3b82e5b6 /src/tag
parent70eb9335bdf56141e697e3d8451ae34db1d8a9f9 (diff)
tag/TagPool: rename struct slot to TagPoolSlot
Diffstat (limited to 'src/tag')
-rw-r--r--src/tag/TagPool.cxx27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/tag/TagPool.cxx b/src/tag/TagPool.cxx
index 5f7a041cd..7e2dfd6b5 100644
--- a/src/tag/TagPool.cxx
+++ b/src/tag/TagPool.cxx
@@ -31,13 +31,13 @@ Mutex tag_pool_lock;
#define NUM_SLOTS 4096
-struct slot {
- struct slot *next;
+struct TagPoolSlot {
+ TagPoolSlot *next;
unsigned char ref;
TagItem item;
} gcc_packed;
-static struct slot *slots[NUM_SLOTS];
+static TagPoolSlot *slots[NUM_SLOTS];
static inline unsigned
calc_hash_n(TagType type, const char *p, size_t length)
@@ -65,19 +65,18 @@ calc_hash(TagType type, const char *p)
return hash ^ type;
}
-static inline struct slot *
+static inline constexpr TagPoolSlot *
tag_item_to_slot(TagItem *item)
{
- return ContainerCast(item, slot, item);
+ return ContainerCast(item, TagPoolSlot, item);
}
-static struct slot *slot_alloc(struct slot *next,
- TagType type,
- const char *value, int length)
+static TagPoolSlot *
+slot_alloc(TagPoolSlot *next, TagType type, const char *value, int length)
{
- struct slot *slot;
+ TagPoolSlot *slot;
- slot = (struct slot *)
+ slot = (TagPoolSlot *)
g_malloc(sizeof(*slot) - sizeof(slot->item.value) + length + 1);
slot->next = next;
slot->ref = 1;
@@ -90,7 +89,7 @@ static struct slot *slot_alloc(struct slot *next,
TagItem *
tag_pool_get_item(TagType type, const char *value, size_t length)
{
- struct slot **slot_p, *slot;
+ TagPoolSlot **slot_p, *slot;
slot_p = &slots[calc_hash_n(type, value, length) % NUM_SLOTS];
for (slot = *slot_p; slot != nullptr; slot = slot->next) {
@@ -112,7 +111,7 @@ tag_pool_get_item(TagType type, const char *value, size_t length)
TagItem *
tag_pool_dup_item(TagItem *item)
{
- struct slot *slot = tag_item_to_slot(item);
+ TagPoolSlot *slot = tag_item_to_slot(item);
assert(slot->ref > 0);
@@ -123,7 +122,7 @@ tag_pool_dup_item(TagItem *item)
/* the reference counter overflows above 0xff;
duplicate the item, and start with 1 */
size_t length = strlen(item->value);
- struct slot **slot_p =
+ TagPoolSlot **slot_p =
&slots[calc_hash_n(item->type, item->value,
length) % NUM_SLOTS];
slot = slot_alloc(*slot_p, item->type,
@@ -136,7 +135,7 @@ tag_pool_dup_item(TagItem *item)
void
tag_pool_put_item(TagItem *item)
{
- struct slot **slot_p, *slot;
+ TagPoolSlot **slot_p, *slot;
slot = tag_item_to_slot(item);
assert(slot->ref > 0);