summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-30 16:55:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-30 16:55:05 +0000
commitf5c05b8c3da2fc70133778daf099b00c5d090ff9 (patch)
treeaab4231c616be2da42da2dc30324f7a2a98387b0 /libc
parent249c30a44ade5e35b88bdba43ed7ad47f540c5ce (diff)
make getnetent.c, md5.c use __uc_malloc
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/getnetent.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c
index d5c25034c..58e679070 100644
--- a/libc/inet/getnetent.c
+++ b/libc/inet/getnetent.c
@@ -19,6 +19,7 @@
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
+#include <malloc.h>
#include <netdb.h>
#include <arpa/inet.h>
@@ -32,14 +33,9 @@ libc_hidden_proto(abort)
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-
-
-#define MAXALIASES 35
static const char NETDB[] = _PATH_NETWORKS;
+
static FILE *netf = NULL;
-static char *line = NULL;
-static struct netent net;
-static char *net_aliases[MAXALIASES];
int _net_stayopen attribute_hidden;
@@ -83,6 +79,22 @@ static char * any(register char *cp, char *match)
return ((char *)0);
}
+#define MAXALIASES 35
+static struct {
+ char *line;
+ struct netent net;
+ char *net_aliases[MAXALIASES];
+} *sp;
+#define line (sp->line)
+#define net (sp->net)
+#define net_aliases (sp->net_aliases)
+#define INIT_SP() { \
+ if (!sp) { \
+ sp = __uc_malloc(sizeof(*sp)); \
+ line = NULL; \
+ } \
+}
+
libc_hidden_proto(getnetent)
struct netent *getnetent(void)
{
@@ -90,6 +102,8 @@ struct netent *getnetent(void)
register char *cp, **q;
struct netent *rv = NULL;
+ INIT_SP();
+
__UCLIBC_MUTEX_LOCK(mylock);
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) {
goto DONE;