-/* $Id$ */
-
/* rl_dns - name resolution (real life) */
-/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
+/* Copyright (c) 2005, 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
const char *gras_os_myname(void)
{
- static char *myname = NULL;
-
- if (myname)
- return (const char *) myname;
+ static char myname[255];
+ static int initialized = 0;
- myname = xbt_new(char, 255);
+ if (initialized)
+ return myname;
if (gethostname(myname, 255) == -1) {
#ifdef HAVE_SYS_SOCKET_H
endhostent();
if (tmp) {
- strncat(myname, tmp->h_name, 255);
+ strncpy(myname, tmp->h_name, 255);
} else {
/* Erm. localhost cannot be resolved. There's something wrong in the user DNS setting */
sprintf(myname, "(misconfigured host)");
myname[254] = '\0';
+ initialized = 1;
return myname;
}