GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /* 00003 ** Written by David Gerdes US Army Construction Engineering Research Lab 00004 ** April 1992 00005 ** Copyright 1992 USA-CERL All rights reserved. 00006 ** 00007 */ 00008 00009 /* 00010 ** takes 1st command line argument and stuffs each letter of it into 00011 ** a linked list. then prints it back out to stdout. 00012 ** If a second argument is specified, the first argument is put in the 00013 ** list backwards. 00014 */ 00015 #include <stdio.h> 00016 #include <grass/linkm.h> 00017 00018 struct link 00019 { 00020 char let; 00021 struct link *next; 00022 }; 00023 00024 int main(int argc, char *argv[]) 00025 { 00026 register int i; 00027 VOID_T *head; 00028 struct link List, *tmp, *p; 00029 int rev = 0; 00030 00031 00032 /* 00033 List.next = NULL; 00034 List.let = ' '; 00035 */ 00036 00037 00038 head = (VOID_T *) link_init(sizeof(struct link)); 00039 00040 00041 for (i = 0; i < 2000000; i++) { 00042 /* 00043 p = (struct link *) malloc (sizeof (struct link)); 00044 free (p); 00045 */ 00046 p = (struct link *)link_new(head); 00047 link_destroy(head, p); 00048 } 00049 00050 link_cleanup(head); 00051 00052 exit(0); 00053 }