]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/home_terminfo.c
ncurses 6.2 - patch 20201010
[ncurses.git] / ncurses / tinfo / home_terminfo.c
index 69d69f95bf7ca817413c1badbe5df656fab78c9b..7e626dfcaad714f8b492719c5fae264f902d3051 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,7 +38,7 @@
 #include <curses.priv.h>
 #include <tic.h>
 
-MODULE_ID("$Id: home_terminfo.c,v 1.12 2010/12/25 23:43:58 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
 
 /* ncurses extension...fall back on user's private directory */
 
@@ -48,16 +49,15 @@ _nc_home_terminfo(void)
 {
     char *result = 0;
 #if USE_HOME_TERMINFO
-    char *home;
-
     if (use_terminfo_vars()) {
+
        if (MyBuffer == 0) {
+           char *home;
+
            if ((home = getenv("HOME")) != 0) {
                size_t want = (strlen(home) + sizeof(PRIVATE_INFO));
-               MyBuffer = typeMalloc(char, want);
-               if (MyBuffer == 0)
-                   _nc_err_abort(MSG_NO_MEMORY);
-               (void) sprintf(MyBuffer, PRIVATE_INFO, home);
+               TYPE_MALLOC(char, want, MyBuffer);
+               _nc_SPRINTF(MyBuffer, _nc_SLIMIT(want) PRIVATE_INFO, home);
            }
        }
        result = MyBuffer;