Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/librecsort/rs-copy.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1996-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* Glenn Fowler <[email protected]> *
19
* *
20
***********************************************************************/
21
/*
22
* copy input records in original order
23
* presumably for the benefit of discipline
24
* function alterations
25
*/
26
27
#include "rshdr.h"
28
29
typedef struct Copy_s
30
{
31
Rsobj_t* head;
32
Rsobj_t* tail;
33
} Copy_t;
34
35
#if __STD_C
36
static int copyinsert(Rs_t* rs, reg Rsobj_t* obj)
37
#else
38
static int copyinsert(rs, obj)
39
Rs_t* rs;
40
reg Rsobj_t* obj;
41
#endif
42
{
43
reg Copy_t* copy = (Copy_t*)rs->methdata;
44
45
if (copy->tail)
46
copy->tail->right = obj;
47
else
48
copy->head = obj;
49
copy->tail = obj;
50
return 0;
51
}
52
53
#if __STD_C
54
static Rsobj_t* copylist(Rs_t* rs)
55
#else
56
static Rsobj_t* copylist(rs)
57
Rs_t* rs;
58
#endif
59
{
60
reg Copy_t* copy = (Copy_t*)rs->methdata;
61
62
if (copy->tail)
63
{
64
copy->tail->right = 0;
65
copy->tail = 0;
66
}
67
return copy->head;
68
}
69
70
static Rsmethod_t _Rscopy =
71
{
72
copyinsert,
73
copylist,
74
sizeof(Copy_t),
75
RS_MTCOPY,
76
"copy",
77
"Copy (no sort)."
78
};
79
80
__DEFINE__(Rsmethod_t*, Rscopy, &_Rscopy);
81
82
#ifdef NoF
83
NoF(rscopy)
84
#endif
85
86