]> www.ginac.de Git - cln.git/blob - src/vector/cl_SV_ringelt.cc
Replace unused macro with cl_unused.
[cln.git] / src / vector / cl_SV_ringelt.cc
1 // cl_make_heap_SV_ringelt().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/SV_ringelt.h"
8
9
10 // Implementation.
11
12 namespace cln {
13
14 static void cl_svector_ringelt_destructor (cl_heap* pointer)
15 {
16         (*(cl_heap_SV_ringelt*)pointer).~cl_heap_SV_ringelt();
17 }
18
19 // XXX: this ought to be static const, but it would be impossible to
20 // set the printing function (see cl_SV_ringelt_debug.cc)
21 cl_class& cl_class_svector_ringelt()
22 {
23         static cl_class instance = {
24                 cl_svector_ringelt_destructor,
25                 0
26         };
27         return instance;
28 }
29
30 cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (std::size_t len)
31 {
32         cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len);
33         hv->refcount = 1;
34         hv->type = &cl_class_svector_ringelt();
35         new (&hv->v) cl_SV_inner<_cl_ring_element> (len);
36         // Have to fill hv->v[i] (0 <= i < len) yourself.
37         return hv;
38 }
39
40 cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (std::size_t len)
41 {
42         cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len);
43         hv->refcount = 1;
44         hv->type = &cl_class_svector_ringelt();
45         new (&hv->v) cl_SV_inner<_cl_ring_element> (len);
46         for (std::size_t i = 0; i < len; i++)
47                 init1(_cl_ring_element, hv->v[i]) ();
48         return hv;
49 }
50
51 // An empty vector.
52 const cl_SV_ringelt cl_null_SV_ringelt = cl_null_SV_ringelt;
53
54 int cl_SV_ringelt_init_helper::count = 0;
55
56 cl_SV_ringelt_init_helper::cl_SV_ringelt_init_helper()
57 {
58         if (count++ == 0)
59                 new ((void *)&cl_null_SV_ringelt) cl_SV_ringelt((std::size_t)0);
60 }
61
62 cl_SV_ringelt_init_helper::~cl_SV_ringelt_init_helper()
63 {
64         if (--count == 0) {
65                 // Nothing to clean up here
66         }
67 }
68
69 }  // namespace cln
70