1 /**************************************************************************/ 2 /* */ 3 /* OCaml */ 4 /* */ 5 /* Contributed by Sylvain Le Gall for Lexifi */ 6 /* */ 7 /* Copyright 2008 Institut National de Recherche en Informatique et */ 8 /* en Automatique. */ 9 /* */ 10 /* All rights reserved. This file is distributed under the terms of */ 11 /* the GNU Lesser General Public License version 2.1, with the */ 12 /* special exception on linking described in the file LICENSE. */ 13 /* */ 14 /**************************************************************************/ 15 16 /* Basic list function in C. */ 17 18 #include "winlist.h" 19 #include <windows.h> 20 list_init(LPLIST lst)21void list_init (LPLIST lst) 22 { 23 lst->lpNext = NULL; 24 } 25 list_cleanup(LPLIST lst)26void list_cleanup (LPLIST lst) 27 { 28 lst->lpNext = NULL; 29 } 30 list_next_set(LPLIST lst,LPLIST next)31void list_next_set (LPLIST lst, LPLIST next) 32 { 33 lst->lpNext = next; 34 } 35 list_next(LPLIST lst)36LPLIST list_next (LPLIST lst) 37 { 38 return lst->lpNext; 39 } 40 list_length(LPLIST lst)41int list_length (LPLIST lst) 42 { 43 int length = 0; 44 LPLIST iter = lst; 45 while (iter != NULL) 46 { 47 length++; 48 iter = list_next(iter); 49 }; 50 return length; 51 } 52 list_concat(LPLIST lsta,LPLIST lstb)53LPLIST list_concat (LPLIST lsta, LPLIST lstb) 54 { 55 LPLIST res = NULL; 56 LPLIST iter = NULL; 57 LPLIST iterPrev = NULL; 58 59 if (lsta == NULL) 60 { 61 res = lstb; 62 } 63 else if (lstb == NULL) 64 { 65 res = lsta; 66 } 67 else 68 { 69 res = lsta; 70 iter = lsta; 71 while (iter != NULL) 72 { 73 iterPrev = iter; 74 iter = list_next(iter); 75 }; 76 iterPrev->lpNext = lstb; 77 }; 78 79 return res; 80 } 81