/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 | 113k | { |
21 | 113k | assert (offsetof(Node,next)==0); |
22 | 113k | const unsigned int ptr_offset = offsetof(Node, data); |
23 | 113k | void * block = malloc( ptr_offset + sizeof(Node) * num ); |
24 | 113k | *reinterpret_cast<void **>(block) = first_block; |
25 | 113k | first_block = block; |
26 | 113k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); |
27 | 113k | Node * i = first; |
28 | 113k | Node * last = i + num; |
29 | 6.86M | while (i + 1 != last) { |
30 | 6.75M | i->next = i + 1; |
31 | 6.75M | i = i + 1; |
32 | 6.75M | } |
33 | 113k | i->next = 0; |
34 | 113k | first_available = first; |
35 | 113k | } acommon::BlockSList<acommon::StringPair>::add_block(unsigned int) Line | Count | Source | 20 | 86.3k | { | 21 | 86.3k | assert (offsetof(Node,next)==0); | 22 | 86.3k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 86.3k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 86.3k | *reinterpret_cast<void **>(block) = first_block; | 25 | 86.3k | first_block = block; | 26 | 86.3k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 86.3k | Node * i = first; | 28 | 86.3k | Node * last = i + num; | 29 | 5.34M | while (i + 1 != last) { | 30 | 5.25M | i->next = i + 1; | 31 | 5.25M | i = i + 1; | 32 | 5.25M | } | 33 | 86.3k | i->next = 0; | 34 | 86.3k | first_available = first; | 35 | 86.3k | } |
acommon::BlockSList<aspeller::Conds const*>::add_block(unsigned int) Line | Count | Source | 20 | 1.10k | { | 21 | 1.10k | assert (offsetof(Node,next)==0); | 22 | 1.10k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 1.10k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 1.10k | *reinterpret_cast<void **>(block) = first_block; | 25 | 1.10k | first_block = block; | 26 | 1.10k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 1.10k | Node * i = first; | 28 | 1.10k | Node * last = i + num; | 29 | 63.1k | while (i + 1 != last) { | 30 | 62.0k | i->next = i + 1; | 31 | 62.0k | i = i + 1; | 32 | 62.0k | } | 33 | 1.10k | i->next = 0; | 34 | 1.10k | first_available = first; | 35 | 1.10k | } |
acommon::BlockSList<char const*>::add_block(unsigned int) Line | Count | Source | 20 | 23.4k | { | 21 | 23.4k | assert (offsetof(Node,next)==0); | 22 | 23.4k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 23.4k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 23.4k | *reinterpret_cast<void **>(block) = first_block; | 25 | 23.4k | first_block = block; | 26 | 23.4k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 23.4k | Node * i = first; | 28 | 23.4k | Node * last = i + num; | 29 | 1.29M | while (i + 1 != last) { | 30 | 1.27M | i->next = i + 1; | 31 | 1.27M | i = i + 1; | 32 | 1.27M | } | 33 | 23.4k | i->next = 0; | 34 | 23.4k | first_available = first; | 35 | 23.4k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::add_block(unsigned int) Line | Count | Source | 20 | 3.07k | { | 21 | 3.07k | assert (offsetof(Node,next)==0); | 22 | 3.07k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 3.07k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 3.07k | *reinterpret_cast<void **>(block) = first_block; | 25 | 3.07k | first_block = block; | 26 | 3.07k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 3.07k | Node * i = first; | 28 | 3.07k | Node * last = i + num; | 29 | 163k | while (i + 1 != last) { | 30 | 159k | i->next = i + 1; | 31 | 159k | i = i + 1; | 32 | 159k | } | 33 | 3.07k | i->next = 0; | 34 | 3.07k | first_available = first; | 35 | 3.07k | } |
|
36 | | |
37 | | template <typename T> |
38 | | void BlockSList<T>::clear() |
39 | 154k | { |
40 | 154k | void * i = first_block; |
41 | 268k | while (i != 0) { |
42 | 113k | void * n = *reinterpret_cast<void **>(i); |
43 | 113k | free(i); |
44 | 113k | i = n; |
45 | 113k | } |
46 | 154k | first_block = 0; |
47 | 154k | first_available = 0; |
48 | 154k | } acommon::BlockSList<acommon::StringPair>::clear() Line | Count | Source | 39 | 114k | { | 40 | 114k | void * i = first_block; | 41 | 200k | while (i != 0) { | 42 | 86.1k | void * n = *reinterpret_cast<void **>(i); | 43 | 86.1k | free(i); | 44 | 86.1k | i = n; | 45 | 86.1k | } | 46 | 114k | first_block = 0; | 47 | 114k | first_available = 0; | 48 | 114k | } |
acommon::BlockSList<aspeller::Conds const*>::clear() Line | Count | Source | 39 | 2.06k | { | 40 | 2.06k | void * i = first_block; | 41 | 3.17k | while (i != 0) { | 42 | 1.10k | void * n = *reinterpret_cast<void **>(i); | 43 | 1.10k | free(i); | 44 | 1.10k | i = n; | 45 | 1.10k | } | 46 | 2.06k | first_block = 0; | 47 | 2.06k | first_available = 0; | 48 | 2.06k | } |
acommon::BlockSList<char const*>::clear() Line | Count | Source | 39 | 31.6k | { | 40 | 31.6k | void * i = first_block; | 41 | 55.1k | while (i != 0) { | 42 | 23.4k | void * n = *reinterpret_cast<void **>(i); | 43 | 23.4k | free(i); | 44 | 23.4k | i = n; | 45 | 23.4k | } | 46 | 31.6k | first_block = 0; | 47 | 31.6k | first_available = 0; | 48 | 31.6k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::clear() Line | Count | Source | 39 | 6.15k | { | 40 | 6.15k | void * i = first_block; | 41 | 9.22k | while (i != 0) { | 42 | 3.07k | void * n = *reinterpret_cast<void **>(i); | 43 | 3.07k | free(i); | 44 | 3.07k | i = n; | 45 | 3.07k | } | 46 | 6.15k | first_block = 0; | 47 | 6.15k | first_available = 0; | 48 | 6.15k | } |
|
49 | | |
50 | | } |
51 | | |
52 | | #endif |