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>
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);
if (result)
{
- char *copy = (char *) malloc (strlen (result) + 1);
+ char *copy = (char *) xmalloc (strlen (result) + 1);
strcpy (copy, result);
return copy;
}
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;
case 'l':
if (! lang)
{
- free (path);
+ xfree (path);
return NULL;
}
case 't':
case 'c':
- free (path);
+ xfree (path);
return NULL;
}
}
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);
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);
if (! file_p (path))
{
- free (path);
+ xfree (path);
return NULL;
}
if (ptr == NULL)
return xstrdup ("/");
- copy = (char *) malloc (strlen (ptr) + 2);
+ copy = (char *) xmalloc (strlen (ptr) + 2);
strcpy (copy, ptr);
strcat (copy, "/");
if (path)
{
db = XrmGetFileDatabase (path);
- free (path);
+ xfree (path);
}
return db;
|| (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;
}
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
{
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);
db = XrmGetFileDatabase (p);
- free (path);
- free (home);
+ xfree (path);
+ xfree (home);
return db;
}
/* 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);