]> git.deb.at Git - pkg/abook.git/blobdiff - misc.c
man page updated
[pkg/abook.git] / misc.c
diff --git a/misc.c b/misc.c
index 29ba73985ff4711753948c2965133aea6ffbe2c0..fa67f0c99a644942f26c2b43af43ca3f85282370 100644 (file)
--- a/misc.c
+++ b/misc.c
 
 #include <assert.h>
 
-char *
-revstr(char *str)
-{
-       char *s, *s2;
-
-       s = s2 = strdup(str);
-
-       while( *str )
-               str++;
-
-       while( *s )
-               *--str = *s++;
-
-       free(s2);
-       return str;
-}
-
-char *
-strupper(char *str)
-{
-       char *tmp = str;
-
-       while( ( *str = toupper( *str ) ) )
-               str++;
-       
-       return tmp;
-}
-
 char *
 strlower(char *str)
 {
        char *tmp = str;
 
+       assert(str != NULL);
+
        while( ( *str = tolower ( *str ) ) )
                str++;
 
@@ -119,6 +93,8 @@ mkstr (const char *format, ... )
                (char *) malloc (size);
 #endif
        
+       assert(format != NULL);
+
        for(;;) {
                int n;
                MY_VA_START(format);
@@ -151,8 +127,7 @@ strconcat (const char *str, ...)
        MY_VA_LOCAL_DECL;
        char *s, *concat;
 
-       if(str == NULL)
-               return NULL;
+       assert(str != NULL);
 
        l = 1 + strlen (str);
        MY_VA_START(str);
@@ -213,10 +188,12 @@ my_getcwd()
        char *dir = NULL;
        int size = 100;
 
-       dir = malloc(size);
+       if( (dir = (char *)malloc(size)) == NULL)
+               return NULL;
        
        while( getcwd(dir, size) == NULL && errno == ERANGE )
-               dir = realloc(dir, size *=2);
+               if( (dir = (char *)realloc(dir, size *=2)) == NULL)
+                       return NULL;
 
        return dir;
 }
@@ -257,7 +234,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;
@@ -273,7 +251,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;