[BACK]Return to utils.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sndiod

Diff for /src/usr.bin/sndiod/utils.c between version 1.7 and 1.8

version 1.7, 2020/01/23 05:40:09 version 1.8, 2021/11/01 14:43:25
Line 188 
Line 188 
         memcpy(p, s, size);          memcpy(p, s, size);
         return p;          return p;
 }  }
   
 /*  
  * copy and append the given string to the name list  
  */  
 void  
 namelist_add(struct name **list, char *str)  
 {  
         struct name *n;  
         size_t size;  
   
         size = strlen(str) + 1;  
         n = xmalloc(sizeof(struct name) + size);  
         memcpy(n->str, str, size);  
         n->next = *list;  
         *list = n;  
 }  
   
 void  
 namelist_clear(struct name **list)  
 {  
         struct name *n;  
   
         while ((n = *list) != NULL) {  
                 *list = n->next;  
                 xfree(n);  
         }  
 }  
   
 char *  
 namelist_byindex(struct name **list, unsigned int idx)  
 {  
         struct name *n;  
   
         n = *list;  
         while (1) {  
                 if (n == NULL)  
                         return NULL;  
                 if (idx == 0)  
                         break;  
                 n = n->next;  
                 idx--;  
         }  
         return n->str;  
 }  

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8