Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!rutgers!okstate!uokmax!rmtodd From: rmtodd@uokmax.UUCP (Richard Michael Todd) Newsgroups: comp.os.minix Subject: calloc and printenv Message-ID: <590@uokmax.UUCP> Date: Thu, 4-Jun-87 23:46:45 EDT Article-I.D.: uokmax.590 Posted: Thu Jun 4 23:46:45 1987 Date-Received: Tue, 9-Jun-87 04:28:57 EDT Organization: University of Oklahoma, Norman, OK Lines: 41 Keywords: calloc, printenv 1. The malloc.c file for the library has functions for malloc, realloc, and free. Strangely enough, calloc is missing. Here's a version of calloc to add to the end of the malloc.c file. ------------------------- cut here ------------------------- /* original lib. didn't include calloc--here it is */ char * calloc(m,size) unsigned m,size; { char *cp; register int i; register char *temp; i = m*size; if ((cp=malloc(i))==(char *)0) return (char *)0; /* malloc succeeded--clear allocated memory */ for (temp = cp ; i-- ; ) *temp++ = '\0'; return cp; } ------------------------- cut here ------------------------- 2. Here's a version of the printenv program to print out all the environment variables currently existing. It isn't anything terribly difficult in terms of programming, but you may find it useful. ------------------------- printenv.c cut here ------------------------- /* ** printenv -- program to print out all environment variables ** Written 5-18-87 by Richard Todd */ main () { extern char **environ; char **sptr; for (sptr = environ ; *sptr ; ++sptr) { printf("%s\n",*sptr); } } ------------------------- printenv.c cut here ------------------------- Richard Todd USSnail:820 Annie Court,Norman OK 73069 UUCP: {allegra!cbosgd|ihnp4}!okstate!uokmax!rmtodd