summaryrefslogtreecommitdiff
path: root/src/xrdb.c
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2010-08-08 13:16:48 -0700
committerDan Nicolaescu <dann@ics.uci.edu>2010-08-08 13:16:48 -0700
commit1b6d8cf08b0e2efa475df6abb4bdedb0b367d853 (patch)
tree991cfd88efa19ac0909f81c11362c9918e80cd51 /src/xrdb.c
parent81ee941084fdb35b93a500f6e763e5b0d1c3ab1b (diff)
downloademacs-1b6d8cf08b0e2efa475df6abb4bdedb0b367d853.tar.gz
emacs-1b6d8cf08b0e2efa475df6abb4bdedb0b367d853.tar.bz2
emacs-1b6d8cf08b0e2efa475df6abb4bdedb0b367d853.zip
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.
Diffstat (limited to 'src/xrdb.c')
-rw-r--r--src/xrdb.c65
1 files changed, 19 insertions, 46 deletions
diff --git a/src/xrdb.c b/src/xrdb.c
index 39637b04081..72b9e07738e 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -20,9 +20,7 @@ GNU General Public License for more details.
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 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
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 @@ x_get_customization_string (XrmDatabase db, const char *name, const char *class)
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 @@ magic_file_p (const char *string, int string_len, const char *class, const char
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 @@ magic_file_p (const char *string, int string_len, const char *class, const char
case 'l':
if (! lang)
{
- free (path);
+ xfree (path);
return NULL;
}
@@ -220,7 +193,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char
case 't':
case 'c':
- free (path);
+ xfree (path);
return NULL;
}
}
@@ -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)
{
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 @@ magic_file_p (const char *string, int string_len, const char *class, const char
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 @@ magic_file_p (const char *string, int string_len, const char *class, const char
if (! file_p (path))
{
- free (path);
+ xfree (path);
return NULL;
}
@@ -298,7 +271,7 @@ gethomedir (void)
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 @@ get_system_app (const char *class)
if (path)
{
db = XrmGetFileDatabase (path);
- free (path);
+ xfree (path);
}
return db;
@@ -409,12 +382,12 @@ get_user_app (const char *class)
|| (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 @@ get_user_db (Display *display)
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 @@ get_environ_db (void)
{
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 @@ get_environ_db (void)
db = XrmGetFileDatabase (p);
- free (path);
- free (home);
+ xfree (path);
+ xfree (home);
return db;
}
@@ -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
to decode paths. */
- free (x_customization_string);
+ xfree (x_customization_string);
x_customization_string
= x_get_customization_string (user_database, myname, myclass);