]> git.deb.at Git - pkg/abook.git/blobdiff - abook.c
- add xstrdup to have proper checking for memory allocation failures
[pkg/abook.git] / abook.c
diff --git a/abook.c b/abook.c
index 4c9df4f1483465d1b320a8da7c652f4adc95f076..557ddb2f5818f7a4c5f9c8d855278aa8dc418747 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -45,7 +45,7 @@ static void           convert(char *srcformat, char *srcfile,
 static void            add_email(int);
 
 char *datafile = NULL;
-char *rcfile = NULL;
+static char *rcfile = NULL;
 
 bool alternative_datafile = FALSE;
 bool alternative_rcfile = FALSE;
@@ -105,7 +105,7 @@ xmalloc_error_handler(int err)
 {
        /*
         * We don't try to save addressbook here because we don't know
-        * if it's fully loaded to to memory.
+        * if it's fully loaded to memory.
         */
        if(is_ui_initialized())
                close_ui();
@@ -125,7 +125,6 @@ init_abook()
                fgetc(stdin);
        }
 
-       signal(SIGKILL, quit_abook_sig);
        signal(SIGTERM, quit_abook_sig);
 
        if(init_ui())
@@ -260,7 +259,7 @@ set_filename(char **var, char *path)
        assert(path != NULL);
 
        if(*path == '/') {
-               *var = strdup(path);
+               *var = xstrdup(path);
                return;
        }
 
@@ -504,7 +503,7 @@ make_mailstr(int item)
 
        ret = *database[item][EMAIL] ?
                mkstr("%s <%s>", name, email) :
-               strdup(name);
+               xstrdup(name);
 
        free(name);
 
@@ -692,7 +691,6 @@ static void
 init_add_email()
 {
        set_filenames();
-       atexit(free_filenames);
        check_abook_directory();
        init_opts();
        load_opts(rcfile);
@@ -747,8 +745,8 @@ add_email_add_item(int quiet, char *name, char *email)
        }
 
        memset(item, 0, sizeof(item));
-       item[NAME] = strdup(name);
-       item[EMAIL] = strdup(email);
+       item[NAME] = xstrdup(name);
+       item[EMAIL] = xstrdup(email);
        add_item2database(item);
 
        return 1;