summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e276c26)
raw | patch | inline | side by side (parent: e276c26)
author | Jeff King <peff@peff.net> | |
Wed, 20 Aug 2008 17:55:33 +0000 (13:55 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 20 Aug 2008 20:30:49 +0000 (13:30 -0700) |
We don't actually modify the struct object, so there is no
reason not to accept const versions (and this allows other
callsites, like the next patch, to use the decoration
machinery).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reason not to accept const versions (and this allows other
callsites, like the next patch, to use the decoration
machinery).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
decorate.c | patch | blob | history | |
decorate.h | patch | blob | history |
diff --git a/decorate.c b/decorate.c
index d9668d2ef94c73e4a7a5602011ff13a9fd9d8c6a..82d9e221eabab53acc418d0db6327e480836a5ed 100644 (file)
--- a/decorate.c
+++ b/decorate.c
#include "object.h"
#include "decorate.h"
-static unsigned int hash_obj(struct object *obj, unsigned int n)
+static unsigned int hash_obj(const struct object *obj, unsigned int n)
{
unsigned int hash = *(unsigned int *)obj->sha1;
return hash % n;
}
-static void *insert_decoration(struct decoration *n, struct object *base, void *decoration)
+static void *insert_decoration(struct decoration *n, const struct object *base, void *decoration)
{
int size = n->size;
struct object_decoration *hash = n->hash;
n->nr = 0;
for (i = 0; i < old_size; i++) {
- struct object *base = old_hash[i].base;
+ const struct object *base = old_hash[i].base;
void *decoration = old_hash[i].decoration;
if (!base)
}
/* Add a decoration pointer, return any old one */
-void *add_decoration(struct decoration *n, struct object *obj, void *decoration)
+void *add_decoration(struct decoration *n, const struct object *obj,
+ void *decoration)
{
int nr = n->nr + 1;
}
/* Lookup a decoration pointer */
-void *lookup_decoration(struct decoration *n, struct object *obj)
+void *lookup_decoration(struct decoration *n, const struct object *obj)
{
int j;
diff --git a/decorate.h b/decorate.h
index 1fa4ad9beb08f23888814b99183487ab85378bfd..e7328044ff84a4acaaa7f5f4bc5f85375dc7a07a 100644 (file)
--- a/decorate.h
+++ b/decorate.h
#define DECORATE_H
struct object_decoration {
- struct object *base;
+ const struct object *base;
void *decoration;
};
struct object_decoration *hash;
};
-extern void *add_decoration(struct decoration *n, struct object *obj, void *decoration);
-extern void *lookup_decoration(struct decoration *n, struct object *obj);
+extern void *add_decoration(struct decoration *n, const struct object *obj, void *decoration);
+extern void *lookup_decoration(struct decoration *n, const struct object *obj);
#endif