Commit 1b6d8cf0 authored by Dan Nicolaescu's avatar Dan Nicolaescu

Cleanup xrdb.c.

* src/xrdb.c: Remove include guard.  Remove
DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
Remove #if 0 code.  Replace malloc->xmalloc, free->xfree,
realloc->xrealloc instead of using #defines.
parent 81ee9410
2010-08-08 Dan Nicolaescu <dann@ics.uci.edu>
* xrdb.c: Remove include guard. Remove
DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
Remove #if 0 code. Replace malloc->xmalloc, free->xfree,
realloc->xrealloc instead of using #defines.
2010-08-08 Eli Zaretskii <eliz@gnu.org> 2010-08-08 Eli Zaretskii <eliz@gnu.org>
* cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line):
......
...@@ -20,9 +20,7 @@ GNU General Public License for more details. ...@@ -20,9 +20,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef emacs
#include <config.h> #include <config.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
...@@ -52,36 +50,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -52,36 +50,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern char *getenv (const char *); extern char *getenv (const char *);
/* This does cause trouble on AIX. I'm going to take the comment at
face value. */
#if 0
extern short getuid (); /* If this causes portability problems,
I think we should just delete it; it'll
default to `int' anyway. */
#endif
#ifdef DECLARE_GETPWUID_WITH_UID_T
extern struct passwd *getpwuid (uid_t); extern struct passwd *getpwuid (uid_t);
extern struct passwd *getpwnam (const char *); extern struct passwd *getpwnam (const char *);
#else
extern struct passwd *getpwuid (uid_t);
extern struct passwd *getpwnam (const char *);
#endif
extern char *get_system_name (void); extern char *get_system_name (void);
/* Make sure not to #include anything after these definitions. Let's
not step on anyone's prototypes. */
#ifdef emacs
/* darwin.h may have already defined these. */
#undef malloc
#undef realloc
#undef free
#define malloc xmalloc
#define realloc xrealloc
#define free xfree
#endif
char *x_get_string_resource (XrmDatabase rdb, const char *name, char *x_get_string_resource (XrmDatabase rdb, const char *name,
const char *class); const char *class);
static int file_p (const char *filename); static int file_p (const char *filename);
...@@ -114,7 +87,7 @@ x_get_customization_string (XrmDatabase db, const char *name, const char *class) ...@@ -114,7 +87,7 @@ x_get_customization_string (XrmDatabase db, const char *name, const char *class)
if (result) if (result)
{ {
char *copy = (char *) malloc (strlen (result) + 1); char *copy = (char *) xmalloc (strlen (result) + 1);
strcpy (copy, result); strcpy (copy, result);
return copy; return copy;
} }
...@@ -159,7 +132,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -159,7 +132,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
char *lang = getenv ("LANG"); char *lang = getenv ("LANG");
int path_size = 100; int path_size = 100;
char *path = (char *) malloc (path_size); char *path = (char *) xmalloc (path_size);
int path_len = 0; int path_len = 0;
const char *p = string; const char *p = string;
...@@ -210,7 +183,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -210,7 +183,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
case 'l': case 'l':
if (! lang) if (! lang)
{ {
free (path); xfree (path);
return NULL; return NULL;
} }
...@@ -220,7 +193,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -220,7 +193,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
case 't': case 't':
case 'c': case 'c':
free (path); xfree (path);
return NULL; return NULL;
} }
} }
...@@ -231,7 +204,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -231,7 +204,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
if (path_len + next_len + 1 > path_size) if (path_len + next_len + 1 > path_size)
{ {
path_size = (path_len + next_len + 1) * 2; path_size = (path_len + next_len + 1) * 2;
path = (char *) realloc (path, path_size); path = (char *) xrealloc (path, path_size);
} }
memcpy (path + path_len, next, next_len); memcpy (path + path_len, next, next_len);
...@@ -257,7 +230,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -257,7 +230,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
if (path_len + suffix_len + 1 > path_size) if (path_len + suffix_len + 1 > path_size)
{ {
path_size = (path_len + suffix_len + 1); path_size = (path_len + suffix_len + 1);
path = (char *) realloc (path, path_size); path = (char *) xrealloc (path, path_size);
} }
memcpy (path + path_len, suffix, suffix_len); memcpy (path + path_len, suffix, suffix_len);
...@@ -268,7 +241,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char ...@@ -268,7 +241,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
if (! file_p (path)) if (! file_p (path))
{ {
free (path); xfree (path);
return NULL; return NULL;
} }
...@@ -298,7 +271,7 @@ gethomedir (void) ...@@ -298,7 +271,7 @@ gethomedir (void)
if (ptr == NULL) if (ptr == NULL)
return xstrdup ("/"); return xstrdup ("/");
copy = (char *) malloc (strlen (ptr) + 2); copy = (char *) xmalloc (strlen (ptr) + 2);
strcpy (copy, ptr); strcpy (copy, ptr);
strcat (copy, "/"); strcat (copy, "/");
...@@ -370,7 +343,7 @@ get_system_app (const char *class) ...@@ -370,7 +343,7 @@ get_system_app (const char *class)
if (path) if (path)
{ {
db = XrmGetFileDatabase (path); db = XrmGetFileDatabase (path);
free (path); xfree (path);
} }
return db; return db;
...@@ -409,12 +382,12 @@ get_user_app (const char *class) ...@@ -409,12 +382,12 @@ get_user_app (const char *class)
|| (file = search_magic_path (free_it, class, "%N", 0))))) || (file = search_magic_path (free_it, class, "%N", 0)))))
{ {
XrmDatabase db = XrmGetFileDatabase (file); XrmDatabase db = XrmGetFileDatabase (file);
free (file); xfree (file);
free (free_it); xfree (free_it);
return db; return db;
} }
free (free_it); xfree (free_it);
return NULL; return NULL;
} }
...@@ -439,12 +412,12 @@ get_user_db (Display *display) ...@@ -439,12 +412,12 @@ get_user_db (Display *display)
char *xdefault; char *xdefault;
home = gethomedir (); home = gethomedir ();
xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults")); xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
strcpy (xdefault, home); strcpy (xdefault, home);
strcat (xdefault, ".Xdefaults"); strcat (xdefault, ".Xdefaults");
db = XrmGetFileDatabase (xdefault); db = XrmGetFileDatabase (xdefault);
free (home); xfree (home);
free (xdefault); xfree (xdefault);
} }
#ifdef HAVE_XSCREENRESOURCESTRING #ifdef HAVE_XSCREENRESOURCESTRING
...@@ -471,7 +444,7 @@ get_environ_db (void) ...@@ -471,7 +444,7 @@ get_environ_db (void)
{ {
home = gethomedir (); home = gethomedir ();
host = get_system_name (); host = get_system_name ();
path = (char *) malloc (strlen (home) path = (char *) xmalloc (strlen (home)
+ sizeof (".Xdefaults-") + sizeof (".Xdefaults-")
+ strlen (host)); + strlen (host));
sprintf (path, "%s%s%s", home, ".Xdefaults-", host); sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
...@@ -480,8 +453,8 @@ get_environ_db (void) ...@@ -480,8 +453,8 @@ get_environ_db (void)
db = XrmGetFileDatabase (p); db = XrmGetFileDatabase (p);
free (path); xfree (path);
free (home); xfree (home);
return db; return db;
} }
...@@ -586,7 +559,7 @@ x_load_resources (Display *display, const char *xrm_string, ...@@ -586,7 +559,7 @@ x_load_resources (Display *display, const char *xrm_string,
/* Figure out what the "customization string" is, so we can use it /* Figure out what the "customization string" is, so we can use it
to decode paths. */ to decode paths. */
free (x_customization_string); xfree (x_customization_string);
x_customization_string x_customization_string
= x_get_customization_string (user_database, myname, myclass); = x_get_customization_string (user_database, myname, myclass);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment