]> git.saurik.com Git - apple/libinfo.git/blobdiff - gen.subproj/getservent.c
Libinfo-278.0.3.tar.gz
[apple/libinfo.git] / gen.subproj / getservent.c
index 16d5cd983dda517a417aae750b17842d084b8701..134fb710fc6f5cba264cde756655327cb57c5759 100644 (file)
@@ -68,7 +68,6 @@ static char sccsid[] = "@(#)getservent.c      8.1 (Berkeley) 6/4/93";
 #define        MAXALIASES      35
 
 static FILE *servf = NULL;
-static char line[BUFSIZ+1];
 static struct servent serv;
 static char *serv_aliases[MAXALIASES];
 int _serv_stayopen;
@@ -98,10 +97,17 @@ struct servent *
 getservent()
 {
        char *p;
+       static char *line = NULL;
        register char *cp, **q;
 
        if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL)
                return (NULL);
+
+       if (line == NULL) {
+               line = malloc(BUFSIZ+1);
+               if (line == NULL)
+                       return (NULL);
+       }
 again:
        if ((p = fgets(line, BUFSIZ, servf)) == NULL)
                return (NULL);