Mercurial > emacs
changeset 109687:d6c4fa12ba52
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.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 08 Aug 2010 13:16:48 -0700 |
parents | 111f90199914 |
children | 3eb5d5708703 |
files | src/ChangeLog src/xrdb.c |
diffstat | 2 files changed, 26 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Sun Aug 08 19:42:47 2010 +0200 +++ b/src/ChangeLog Sun Aug 08 13:16:48 2010 -0700 @@ -1,3 +1,10 @@ +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> * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line):
--- a/src/xrdb.c Sun Aug 08 19:42:47 2010 +0200 +++ b/src/xrdb.c Sun Aug 08 13:16:48 2010 -0700 @@ -20,9 +20,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef emacs #include <config.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -52,36 +50,11 @@ 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 *getpwnam (const char *); -#else extern struct passwd *getpwuid (uid_t); extern struct passwd *getpwnam (const char *); -#endif 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, const char *class); static int file_p (const char *filename); @@ -114,7 +87,7 @@ if (result) { - char *copy = (char *) malloc (strlen (result) + 1); + char *copy = (char *) xmalloc (strlen (result) + 1); strcpy (copy, result); return copy; } @@ -159,7 +132,7 @@ char *lang = getenv ("LANG"); int path_size = 100; - char *path = (char *) malloc (path_size); + char *path = (char *) xmalloc (path_size); int path_len = 0; const char *p = string; @@ -210,7 +183,7 @@ case 'l': if (! lang) { - free (path); + xfree (path); return NULL; } @@ -220,7 +193,7 @@ case 't': case 'c': - free (path); + xfree (path); return NULL; } } @@ -231,7 +204,7 @@ if (path_len + next_len + 1 > path_size) { 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); @@ -257,7 +230,7 @@ if (path_len + suffix_len + 1 > path_size) { 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); @@ -268,7 +241,7 @@ if (! file_p (path)) { - free (path); + xfree (path); return NULL; } @@ -298,7 +271,7 @@ if (ptr == NULL) return xstrdup ("/"); - copy = (char *) malloc (strlen (ptr) + 2); + copy = (char *) xmalloc (strlen (ptr) + 2); strcpy (copy, ptr); strcat (copy, "/"); @@ -370,7 +343,7 @@ if (path) { db = XrmGetFileDatabase (path); - free (path); + xfree (path); } return db; @@ -409,12 +382,12 @@ || (file = search_magic_path (free_it, class, "%N", 0))))) { XrmDatabase db = XrmGetFileDatabase (file); - free (file); - free (free_it); + xfree (file); + xfree (free_it); return db; } - free (free_it); + xfree (free_it); return NULL; } @@ -439,12 +412,12 @@ char *xdefault; home = gethomedir (); - xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults")); + xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults")); strcpy (xdefault, home); strcat (xdefault, ".Xdefaults"); db = XrmGetFileDatabase (xdefault); - free (home); - free (xdefault); + xfree (home); + xfree (xdefault); } #ifdef HAVE_XSCREENRESOURCESTRING @@ -471,7 +444,7 @@ { home = gethomedir (); host = get_system_name (); - path = (char *) malloc (strlen (home) + path = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults-") + strlen (host)); sprintf (path, "%s%s%s", home, ".Xdefaults-", host); @@ -480,8 +453,8 @@ db = XrmGetFileDatabase (p); - free (path); - free (home); + xfree (path); + xfree (home); return db; } @@ -586,7 +559,7 @@ /* Figure out what the "customization string" is, so we can use it to decode paths. */ - free (x_customization_string); + xfree (x_customization_string); x_customization_string = x_get_customization_string (user_database, myname, myclass);