From e4da30858037b431880263676e8f90b1f8412a38 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 18 Nov 2006 20:53:44 +0000 Subject: Fix from Eli for incorrect value of $(MAKE) on Cygwin. A few changes from char* to void* where appropriate, and removing of unnecessary casts. Much more work on const-ifying the codebase. This round involves some code changes to make it correct. NOTE!! There will almost certainly be problems on the non-POSIX ports that will need to be addressed after the const changes are finished: they will need to be const-ified properly and there may need to be some changes to allocate memory, etc. as well. The next (last?) big push for this, still to come, is const-ifying the filenames in struct file, struct dep, etc. This will allow us to store file names in the string cache and finally resolve Savannah bug #15182 (make uses too much memory), among other advantages. --- strcache.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'strcache.c') diff --git a/strcache.c b/strcache.c index 33dcaf1..5b72399 100644 --- a/strcache.c +++ b/strcache.c @@ -155,11 +155,17 @@ strcache_add (const char *str) const char * strcache_add_len (const char *str, int len) { - char *key = alloca (len + 1); - memcpy (key, str, len); - key[len] = '\0'; + /* If we're not given a nul-terminated string we have to create one, because + the hashing functions expect it. */ + if (str[len] != '\0') + { + char *key = alloca (len + 1); + memcpy (key, str, len); + key[len] = '\0'; + str = key; + } - return add_hash (key, len); + return add_hash (str, len); } int -- cgit v1.2.3