]> www.ginac.de Git - cln.git/blob - src/vector/cl_SV_ringelt.cc
Initial revision
[cln.git] / src / vector / cl_SV_ringelt.cc
1 // cl_make_heap_SV_ringelt().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 CL_PROVIDE(cl_SV_ringelt)
7
8 // Specification.
9 #include "cl_SV_ringelt.h"
10
11
12 // Implementation.
13
14 #include "cl_abort.h"
15
16
17 static void cl_svector_ringelt_destructor (cl_heap* pointer)
18 {
19 #if (defined(__mips__) || defined(__mips64__)) && !defined(__GNUC__) // workaround SGI CC bug
20         (*(cl_heap_SV_ringelt*)pointer).~cl_heap_SV();
21 #else
22         (*(cl_heap_SV_ringelt*)pointer).~cl_heap_SV_ringelt();
23 #endif
24 }
25
26 cl_class cl_class_svector_ringelt = {
27         cl_svector_ringelt_destructor,
28         0
29 };
30
31 cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintL len)
32 {
33         var cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) cl_malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len);
34         hv->refcount = 1;
35         hv->type = &cl_class_svector_ringelt;
36         new (&hv->v) cl_SV_inner<_cl_ring_element> (len);
37         // Have to fill hv->v[i] (0 <= i < len) yourself.
38         return hv;
39 }
40
41 cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (uintL len)
42 {
43         var cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) cl_malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len);
44         hv->refcount = 1;
45         hv->type = &cl_class_svector_ringelt;
46         new (&hv->v) cl_SV_inner<_cl_ring_element> (len);
47         for (var uintL i = 0; i < len; i++)
48                 init1(_cl_ring_element, hv->v[i]) ();
49         return hv;
50 }
51
52 // An empty vector.
53 const cl_SV_ringelt cl_null_SV_ringelt = cl_SV_ringelt((uintL)0);
54
55 CL_PROVIDE_END(cl_SV_ringelt)