File: slist.c

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (67 lines) | stat: -rw-r--r-- 983 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

/*
** Copyright (C) 1997 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
**
** $Id: slist.c,v 1.2 1997/07/27 14:59:29 fjh Exp $
*/

/* Imports */
#include	<assert.h> /* for assert */

#include	"mem.h" /* for MB_malloc */
#include	"slist.h"

/* Exported definitions */

/* Local declarations */

static char
rcs_id[]	= "$Id: slist.c,v 1.2 1997/07/27 14:59:29 fjh Exp $";

/* Implementation */

SList
slist_nil()
{
	return (SList) NULL;
}

MB_Bool
slist_null(SList list)
{
	return NULL == list;
}

SList
slist_cons(void *head, SList tail)
{
	p_SList_Node	*tmp;

	tmp = (SList) MB_malloc(sizeof(p_SList_Node));

	tmp->p_head = head;
	tmp->p_tail = tail;

	return tmp;
}


void *
slist_head(SList list)
{
	assert(list != NULL); /* XXX */
	
	return list->p_head;
}

SList
slist_tail(SList list)
{
	assert(list != NULL); /* XXX */

	return list->p_tail;
}