]> git.deb.at Git - pkg/abook.git/blobdiff - misc.c
initial custom field support
[pkg/abook.git] / misc.c
diff --git a/misc.c b/misc.c
index 1eadf97b19e4edc9fc43ce76196475df1e3bec69..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);
@@ -220,11 +190,13 @@ my_getcwd()
        char *dir = NULL;
        int size = 100;
 
-       if( (dir = malloc(size)) == NULL)
+       if( (dir = (char *)malloc(size)) == NULL)
                return NULL;
+
+       *dir = 0;
        
        while( getcwd(dir, size) == NULL && errno == ERANGE )
-               if( (dir = realloc(dir, size *=2)) == NULL)
+               if( (dir = (char *)realloc(dir, size *=2)) == NULL)
                        return NULL;
 
        return dir;
@@ -266,7 +238,8 @@ getaline(FILE *f)
                        break;          /* the whole line has been read */
 
                for (inc = size, p = NULL; inc > mininc; inc /= 2)
-                       if ((p = abook_realloc(buf, size + inc)) != NULL)
+                       if ((p = (char *)abook_realloc(buf, size + inc)) !=
+                                       NULL)
                                break;
 
                size += inc;
@@ -282,7 +255,7 @@ getaline(FILE *f)
                buf[--len] = '\0';
 
        if (size - len > mucho) { /* a plenitude of unused memory? */
-               p = abook_realloc(buf, len+1);
+               p = (char *)abook_realloc(buf, len+1);
                if (p != NULL) {
                        buf = p;
                        size = len+1;