summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-10-16 21:55:49 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-10-17 02:54:57 -0400
commit4049b9cfc082affc6365539138f6f5c546bb5685 (patch)
tree37c698b4622297eba91925d00eeb97094e95f141 /pack-write.c
parent7ba502c47bda21d060844863991083f4c319d436 (diff)
downloadgit-4049b9cfc082affc6365539138f6f5c546bb5685.tar.gz
fix const issues with some functions
Two functions, namely write_idx_file() and open_pack_file(), currently return a const pointer. However that pointer is either a copy of the first argument, or set to a malloc'd buffer when that first argument is null. In the later case it is wrong to qualify that pointer as const since ownership of the buffer is transferred to the caller to dispose of, and obviously the free() function is not meant to be passed const pointers. Making the return pointer not const causes a warning when the first argument is returned since that argument is also marked const. The correct thing to do is therefore to remove the const qualifiers, avoiding the need for ugly casts only to silence some warnings. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pack-write.c b/pack-write.c
index e59b197e5e..d1ed3abe21 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -17,7 +17,8 @@ static int sha1_compare(const void *_a, const void *_b)
* the SHA1 hash of sorted object names. The objects array passed in
* will be sorted by SHA1 on exit.
*/
-const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)
+char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
+ int nr_objects, unsigned char *sha1)
{
struct sha1file *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;