6 static Tag
*table
[4096];
10 static int tag_hash(char *name
)
12 uintptr_t l
= (uintptr_t)name
;
21 static Tag
*find_tag(char *name
)
23 int hash
= tag_hash(name
);
25 for (tag
= table
[hash
]; tag
; tag
= tag
->hash_next
)
26 if (tag
->name
== name
)
28 tag
= calloc(1, sizeof(Tag
));
30 tag
->hash_next
= table
[hash
];
37 /* the last argument is a sham */
38 void tag_commit(rev_commit
*c
, char *name
)
40 Tag
*tag
= find_tag(name
);
41 if (tag
->last
== this_file
->name
) {
42 fprintf(stderr
, "duplicate tag %s in %s, ignoring\n",
43 name
, this_file
->name
);
46 tag
->last
= this_file
->name
;
48 Chunk
*v
= malloc(sizeof(Chunk
));
49 v
->next
= tag
->commits
;
53 tag
->commits
->v
[--tag
->left
] = c
;
57 rev_commit
**tagged(Tag
*tag
)
59 rev_commit
**v
= NULL
;
62 rev_commit
**p
= malloc(tag
->count
* sizeof(*p
));
63 Chunk
*c
= tag
->commits
;
64 int n
= Ncommits
- tag
->left
;
67 memcpy(p
, c
->v
+ tag
->left
, n
* sizeof(*p
));
69 for (c
= c
->next
, p
+= n
; c
; c
= c
->next
, p
+= Ncommits
)
70 memcpy(p
, c
->v
, Ncommits
* sizeof(*p
));
75 void discard_tags(void)
81 Chunk
*c
= tag
->commits
;
83 Chunk
*next
= c
->next
;