1 /* hello world - multiple sources of data (still no data copying) */ 2 3 #include "ex_hello_world.h" /* helper functions */ 4 main(void)5int main(void) 6 { 7 Vstr_base *s1 = hw_init(); 8 9 vstr_add_cstr_ptr(s1, s1->len, "Hello"); 10 vstr_add_cstr_ptr(s1, s1->len, " "); 11 vstr_add_cstr_ptr(s1, s1->len, "World\n"); 12 13 /* we are checking whether any of the above three functions failed here */ 14 if (s1->conf->malloc_bad) 15 errno = ENOMEM, err(EXIT_FAILURE, "Add string data"); 16 17 /* loop until all data is output... */ 18 while (io_put(s1, STDOUT_FILENO) != IO_NONE) {} 19 20 exit (hw_exit(s1)); 21 } 22