summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8dbbd14)
raw | patch | inline | side by side (parent: 8dbbd14)
author | Linus Torvalds <torvalds@osdl.org> | |
Fri, 30 Jun 2006 04:38:55 +0000 (21:38 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 30 Jun 2006 06:48:31 +0000 (23:48 -0700) |
There are a few special places where some programs accessed the object
hash array directly, which bothered me because I wanted to play with some
simple re-organizations.
So this patch makes the object hash array data structures all entirely
local to object.c, and the few users who wanted to look at it now get to
use a function to query how many object index entries there can be, and to
actually access the array.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
hash array directly, which bothered me because I wanted to play with some
simple re-organizations.
So this patch makes the object hash array data structures all entirely
local to object.c, and the few users who wanted to look at it now get to
use a function to query how many object index entries there can be, and to
actually access the array.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
fsck-objects.c | patch | blob | history | |
name-rev.c | patch | blob | history | |
object.c | patch | blob | history | |
object.h | patch | blob | history |
diff --git a/fsck-objects.c b/fsck-objects.c
index 769bb2a6a75f34192cfd7d6f99ea8f6efbfdce7e..ef54a8a411b01bb4f6becd24c68fad3fcbd15211 100644 (file)
--- a/fsck-objects.c
+++ b/fsck-objects.c
static void check_connectivity(void)
{
- int i;
+ int i, max;
/* Look up all the requirements, warn about missing objects.. */
- for (i = 0; i < obj_allocs; i++) {
+ max = get_max_object_index();
+ for (i = 0; i < max; i++) {
const struct object_refs *refs;
- struct object *obj = objs[i];
+ struct object *obj = get_indexed_object(i);
if (!obj)
continue;
diff --git a/name-rev.c b/name-rev.c
index 3a5ac35d163bae5431c9cad8c9e31918c2734241..6a23f2d8a2d87c46ac9e1ec7bcb36e540967f93b 100644 (file)
--- a/name-rev.c
+++ b/name-rev.c
fwrite(p_start, p - p_start, 1, stdout);
}
} else if (all) {
- int i;
+ int i, max;
- for (i = 0; i < obj_allocs; i++)
- if (objs[i])
- printf("%s %s\n", sha1_to_hex(objs[i]->sha1),
- get_rev_name(objs[i]));
+ max = get_max_object_index();
+ for (i = 0; i < max; i++) {
+ struct object * obj = get_indexed_object(i);
+ if (!obj)
+ continue;
+ printf("%s %s\n", sha1_to_hex(obj->sha1), get_rev_name(obj));
+ }
} else {
int i;
for (i = 0; i < revs.nr; i++)
diff --git a/object.c b/object.c
index 37784cee9a90a7e5b44dd660d6b7ea9191b59486..31c77ea03a2083ce9ed7c71a2b4d90fb6b944c78 100644 (file)
--- a/object.c
+++ b/object.c
#include "commit.h"
#include "tag.h"
-struct object **objs;
-static int nr_objs;
-int obj_allocs;
+static struct object **objs;
+static int nr_objs, obj_allocs;
+
+unsigned int get_max_object_index(void)
+{
+ return obj_allocs;
+}
+
+struct object *get_indexed_object(unsigned int idx)
+{
+ return objs[idx];
+}
const char *type_names[] = {
"none", "blob", "tree", "commit", "bad"
diff --git a/object.h b/object.h
index 6f23a9a18099cbc9fdc827f53843b1157dd10935..e0125e154fd970209d30138858f31ef2017651ac 100644 (file)
--- a/object.h
+++ b/object.h
};
extern int track_object_refs;
-extern int obj_allocs;
-extern struct object **objs;
extern const char *type_names[];
+extern unsigned int get_max_object_index(void);
+extern struct object *get_indexed_object(unsigned int);
+
static inline const char *typename(unsigned int type)
{
return type_names[type > TYPE_TAG ? TYPE_BAD : type];