]> git.deb.at Git - pkg/abook.git/blobdiff - misc.c
buffer length calculation changes
[pkg/abook.git] / misc.c
diff --git a/misc.c b/misc.c
index 7bf2f8fc1380f9a6b6c55f2059725c2da0afb6b2..8a4b9cfc5d2657fbb8ed69076c849d88b1efa5f6 100644 (file)
--- a/misc.c
+++ b/misc.c
 
 #include <assert.h>
 
-char *
-revstr(char *str)
-{
-       char *s, *s2;
-
-       assert(str != NULL);
-
-       s = s2 = strdup(str);
-
-       while( *str )
-               str++;
-
-       while( *s )
-               *--str = *s++;
-
-       free(s2);
-       return str;
-}
-
-char *
-strupper(char *str)
-{
-       char *tmp = str;
-
-       assert(str != NULL);
-
-       while( ( *str = toupper( *str ) ) )
-               str++;
-       
-       return tmp;
-}
-
 char *
 strlower(char *str)
 {
@@ -155,7 +123,7 @@ mkstr (const char *format, ... )
 char*
 strconcat (const char *str, ...)
 {
-       int   l;
+       unsigned long l;
        MY_VA_LOCAL_DECL;
        char *s, *concat;
 
@@ -176,6 +144,8 @@ strconcat (const char *str, ...)
 #else
        malloc(l);
 #endif
+       if(concat == NULL)
+               return NULL;
 
        strcpy (concat, str);
        MY_VA_START(str);
@@ -222,6 +192,8 @@ my_getcwd()
 
        if( (dir = (char *)malloc(size)) == NULL)
                return NULL;
+
+       *dir = 0;
        
        while( getcwd(dir, size) == NULL && errno == ERANGE )
                if( (dir = (char *)realloc(dir, size *=2)) == NULL)