Skip to content

Commit 11f9e8d

Browse files
derrickstoleegitster
authored andcommitted
cache: use const char * for get_object_directory()
The get_object_directory() method returns the exact string stored at the_repository->objects->odb->path. The return type of "char *" implies that the caller must keep track of the buffer and free() it when complete. This causes significant problems later when the ODB is accessed. Use "const char *" as the return type to avoid this confusion. There are no current callers that care about the non-const definition. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b56166c commit 11f9e8d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ extern char *git_work_tree_cfg;
567567
int is_inside_work_tree(void);
568568
const char *get_git_dir(void);
569569
const char *get_git_common_dir(void);
570-
char *get_object_directory(void);
570+
const char *get_object_directory(void);
571571
char *get_index_file(void);
572572
char *get_graft_file(struct repository *r);
573573
void set_git_dir(const char *path, int make_realpath);

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ const char *get_git_work_tree(void)
271271
return the_repository->worktree;
272272
}
273273

274-
char *get_object_directory(void)
274+
const char *get_object_directory(void)
275275
{
276276
if (!the_repository->objects->odb)
277277
BUG("git environment hasn't been setup");

0 commit comments

Comments
 (0)