/src/aspell/common/block_slist-t.hpp
Line | Count | Source |
1 | | // This file is part of The New Aspell |
2 | | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license |
3 | | // version 2.0 or 2.1. You should have received a copy of the LGPL |
4 | | // license along with this library if you did not you can find |
5 | | // it at http://www.gnu.org/. |
6 | | |
7 | | #ifndef autil__block_slist_t_hh |
8 | | #define autil__block_slist_t_hh |
9 | | |
10 | | #include <cstddef> |
11 | | #include <cstdlib> |
12 | | #include <cassert> |
13 | | |
14 | | #include "block_slist.hpp" |
15 | | |
16 | | namespace acommon { |
17 | | |
18 | | template <typename T> |
19 | | void BlockSList<T>::add_block(unsigned int num) |
20 | 88.3k | { |
21 | 88.3k | assert (offsetof(Node,next)==0); |
22 | 88.3k | const unsigned int ptr_offset = offsetof(Node, data); |
23 | 88.3k | void * block = malloc( ptr_offset + sizeof(Node) * num ); |
24 | 88.3k | *reinterpret_cast<void **>(block) = first_block; |
25 | 88.3k | first_block = block; |
26 | 88.3k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); |
27 | 88.3k | Node * i = first; |
28 | 88.3k | Node * last = i + num; |
29 | 5.09M | while (i + 1 != last) { |
30 | 5.00M | i->next = i + 1; |
31 | 5.00M | i = i + 1; |
32 | 5.00M | } |
33 | 88.3k | i->next = 0; |
34 | 88.3k | first_available = first; |
35 | 88.3k | } acommon::BlockSList<acommon::StringPair>::add_block(unsigned int) Line | Count | Source | 20 | 53.4k | { | 21 | 53.4k | assert (offsetof(Node,next)==0); | 22 | 53.4k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 53.4k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 53.4k | *reinterpret_cast<void **>(block) = first_block; | 25 | 53.4k | first_block = block; | 26 | 53.4k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 53.4k | Node * i = first; | 28 | 53.4k | Node * last = i + num; | 29 | 3.13M | while (i + 1 != last) { | 30 | 3.07M | i->next = i + 1; | 31 | 3.07M | i = i + 1; | 32 | 3.07M | } | 33 | 53.4k | i->next = 0; | 34 | 53.4k | first_available = first; | 35 | 53.4k | } |
acommon::BlockSList<aspeller::Conds const*>::add_block(unsigned int) Line | Count | Source | 20 | 1.26k | { | 21 | 1.26k | assert (offsetof(Node,next)==0); | 22 | 1.26k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 1.26k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 1.26k | *reinterpret_cast<void **>(block) = first_block; | 25 | 1.26k | first_block = block; | 26 | 1.26k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 1.26k | Node * i = first; | 28 | 1.26k | Node * last = i + num; | 29 | 74.3k | while (i + 1 != last) { | 30 | 73.1k | i->next = i + 1; | 31 | 73.1k | i = i + 1; | 32 | 73.1k | } | 33 | 1.26k | i->next = 0; | 34 | 1.26k | first_available = first; | 35 | 1.26k | } |
acommon::BlockSList<char const*>::add_block(unsigned int) Line | Count | Source | 20 | 30.2k | { | 21 | 30.2k | assert (offsetof(Node,next)==0); | 22 | 30.2k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 30.2k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 30.2k | *reinterpret_cast<void **>(block) = first_block; | 25 | 30.2k | first_block = block; | 26 | 30.2k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 30.2k | Node * i = first; | 28 | 30.2k | Node * last = i + num; | 29 | 1.71M | while (i + 1 != last) { | 30 | 1.68M | i->next = i + 1; | 31 | 1.68M | i = i + 1; | 32 | 1.68M | } | 33 | 30.2k | i->next = 0; | 34 | 30.2k | first_available = first; | 35 | 30.2k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::add_block(unsigned int) Line | Count | Source | 20 | 3.35k | { | 21 | 3.35k | assert (offsetof(Node,next)==0); | 22 | 3.35k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 3.35k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 3.35k | *reinterpret_cast<void **>(block) = first_block; | 25 | 3.35k | first_block = block; | 26 | 3.35k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 3.35k | Node * i = first; | 28 | 3.35k | Node * last = i + num; | 29 | 178k | while (i + 1 != last) { | 30 | 174k | i->next = i + 1; | 31 | 174k | i = i + 1; | 32 | 174k | } | 33 | 3.35k | i->next = 0; | 34 | 3.35k | first_available = first; | 35 | 3.35k | } |
|
36 | | |
37 | | template <typename T> |
38 | | void BlockSList<T>::clear() |
39 | 116k | { |
40 | 116k | void * i = first_block; |
41 | 204k | while (i != 0) { |
42 | 88.1k | void * n = *reinterpret_cast<void **>(i); |
43 | 88.1k | free(i); |
44 | 88.1k | i = n; |
45 | 88.1k | } |
46 | 116k | first_block = 0; |
47 | 116k | first_available = 0; |
48 | 116k | } acommon::BlockSList<acommon::StringPair>::clear() Line | Count | Source | 39 | 70.7k | { | 40 | 70.7k | void * i = first_block; | 41 | 123k | while (i != 0) { | 42 | 53.2k | void * n = *reinterpret_cast<void **>(i); | 43 | 53.2k | free(i); | 44 | 53.2k | i = n; | 45 | 53.2k | } | 46 | 70.7k | first_block = 0; | 47 | 70.7k | first_available = 0; | 48 | 70.7k | } |
acommon::BlockSList<aspeller::Conds const*>::clear() Line | Count | Source | 39 | 2.26k | { | 40 | 2.26k | void * i = first_block; | 41 | 3.52k | while (i != 0) { | 42 | 1.26k | void * n = *reinterpret_cast<void **>(i); | 43 | 1.26k | free(i); | 44 | 1.26k | i = n; | 45 | 1.26k | } | 46 | 2.26k | first_block = 0; | 47 | 2.26k | first_available = 0; | 48 | 2.26k | } |
acommon::BlockSList<char const*>::clear() Line | Count | Source | 39 | 37.0k | { | 40 | 37.0k | void * i = first_block; | 41 | 67.3k | while (i != 0) { | 42 | 30.2k | void * n = *reinterpret_cast<void **>(i); | 43 | 30.2k | free(i); | 44 | 30.2k | i = n; | 45 | 30.2k | } | 46 | 37.0k | first_block = 0; | 47 | 37.0k | first_available = 0; | 48 | 37.0k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::clear() Line | Count | Source | 39 | 6.71k | { | 40 | 6.71k | void * i = first_block; | 41 | 10.0k | while (i != 0) { | 42 | 3.35k | void * n = *reinterpret_cast<void **>(i); | 43 | 3.35k | free(i); | 44 | 3.35k | i = n; | 45 | 3.35k | } | 46 | 6.71k | first_block = 0; | 47 | 6.71k | first_available = 0; | 48 | 6.71k | } |
|
49 | | |
50 | | } |
51 | | |
52 | | #endif |