~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to otherlibs/win32unix/winlist.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2009-02-22 08:49:13 UTC
  • mfrom: (12.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090222084913-3i0uw2bhd0lgw0ok
* Uploading to unstable
* debian/control: bump dh-ocaml to (>= 0.4) to avoid buggy ocamlinit.mk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***********************************************************************/
 
2
/*                                                                     */
 
3
/*                           Objective Caml                            */
 
4
/*                                                                     */
 
5
/*  Contributed by Sylvain Le Gall for Lexifi                          */
 
6
/*                                                                     */
 
7
/*  Copyright 2008 Institut National de Recherche en Informatique et   */
 
8
/*  en Automatique.  All rights reserved.  This file is distributed    */
 
9
/*  under the terms of the GNU Library General Public License, with    */
 
10
/*  the special exception on linking described in file ../../LICENSE.  */
 
11
/*                                                                     */
 
12
/***********************************************************************/
 
13
 
 
14
/* $Id: winlist.c,v 1.2 2008/07/31 12:09:18 xleroy Exp $ */
 
15
 
 
16
/* Basic list function in C. */
 
17
 
 
18
#include "winlist.h"
 
19
#include <windows.h>
 
20
 
 
21
void list_init (LPLIST lst)
 
22
{
 
23
  lst->lpNext = NULL;
 
24
}
 
25
 
 
26
void list_cleanup (LPLIST lst)
 
27
{
 
28
  lst->lpNext = NULL;
 
29
}
 
30
 
 
31
void list_next_set (LPLIST lst, LPLIST next)
 
32
{
 
33
  lst->lpNext = next;
 
34
}
 
35
 
 
36
LPLIST list_next (LPLIST lst)
 
37
{
 
38
  return lst->lpNext;
 
39
}
 
40
 
 
41
int 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
 
 
53
LPLIST 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
}