/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 | 45.2k | { |
21 | 45.2k | assert (offsetof(Node,next)==0); |
22 | 45.2k | const unsigned int ptr_offset = offsetof(Node, data); |
23 | 45.2k | void * block = malloc( ptr_offset + sizeof(Node) * num ); |
24 | 45.2k | *reinterpret_cast<void **>(block) = first_block; |
25 | 45.2k | first_block = block; |
26 | 45.2k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); |
27 | 45.2k | Node * i = first; |
28 | 45.2k | Node * last = i + num; |
29 | 2.62M | while (i + 1 != last) { |
30 | 2.57M | i->next = i + 1; |
31 | 2.57M | i = i + 1; |
32 | 2.57M | } |
33 | 45.2k | i->next = 0; |
34 | 45.2k | first_available = first; |
35 | 45.2k | } acommon::BlockSList<acommon::StringPair>::add_block(unsigned int) Line | Count | Source | 20 | 15.9k | { | 21 | 15.9k | assert (offsetof(Node,next)==0); | 22 | 15.9k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 15.9k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 15.9k | *reinterpret_cast<void **>(block) = first_block; | 25 | 15.9k | first_block = block; | 26 | 15.9k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 15.9k | Node * i = first; | 28 | 15.9k | Node * last = i + num; | 29 | 916k | while (i + 1 != last) { | 30 | 900k | i->next = i + 1; | 31 | 900k | i = i + 1; | 32 | 900k | } | 33 | 15.9k | i->next = 0; | 34 | 15.9k | first_available = first; | 35 | 15.9k | } |
acommon::BlockSList<aspeller::Conds const*>::add_block(unsigned int) Line | Count | Source | 20 | 1.11k | { | 21 | 1.11k | assert (offsetof(Node,next)==0); | 22 | 1.11k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 1.11k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 1.11k | *reinterpret_cast<void **>(block) = first_block; | 25 | 1.11k | first_block = block; | 26 | 1.11k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 1.11k | Node * i = first; | 28 | 1.11k | Node * last = i + num; | 29 | 63.8k | while (i + 1 != last) { | 30 | 62.7k | i->next = i + 1; | 31 | 62.7k | i = i + 1; | 32 | 62.7k | } | 33 | 1.11k | i->next = 0; | 34 | 1.11k | first_available = first; | 35 | 1.11k | } |
acommon::BlockSList<char const*>::add_block(unsigned int) Line | Count | Source | 20 | 25.1k | { | 21 | 25.1k | assert (offsetof(Node,next)==0); | 22 | 25.1k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 25.1k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 25.1k | *reinterpret_cast<void **>(block) = first_block; | 25 | 25.1k | first_block = block; | 26 | 25.1k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 25.1k | Node * i = first; | 28 | 25.1k | Node * last = i + num; | 29 | 1.47M | while (i + 1 != last) { | 30 | 1.45M | i->next = i + 1; | 31 | 1.45M | i = i + 1; | 32 | 1.45M | } | 33 | 25.1k | i->next = 0; | 34 | 25.1k | first_available = first; | 35 | 25.1k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::add_block(unsigned int) Line | Count | Source | 20 | 3.08k | { | 21 | 3.08k | assert (offsetof(Node,next)==0); | 22 | 3.08k | const unsigned int ptr_offset = offsetof(Node, data); | 23 | 3.08k | void * block = malloc( ptr_offset + sizeof(Node) * num ); | 24 | 3.08k | *reinterpret_cast<void **>(block) = first_block; | 25 | 3.08k | first_block = block; | 26 | 3.08k | Node * first = reinterpret_cast<Node *>(reinterpret_cast<char *>(block) + ptr_offset); | 27 | 3.08k | Node * i = first; | 28 | 3.08k | Node * last = i + num; | 29 | 163k | while (i + 1 != last) { | 30 | 160k | i->next = i + 1; | 31 | 160k | i = i + 1; | 32 | 160k | } | 33 | 3.08k | i->next = 0; | 34 | 3.08k | first_available = first; | 35 | 3.08k | } |
|
36 | | |
37 | | template <typename T> |
38 | | void BlockSList<T>::clear() |
39 | 63.0k | { |
40 | 63.0k | void * i = first_block; |
41 | 108k | while (i != 0) { |
42 | 45.1k | void * n = *reinterpret_cast<void **>(i); |
43 | 45.1k | free(i); |
44 | 45.1k | i = n; |
45 | 45.1k | } |
46 | 63.0k | first_block = 0; |
47 | 63.0k | first_available = 0; |
48 | 63.0k | } acommon::BlockSList<acommon::StringPair>::clear() Line | Count | Source | 39 | 20.9k | { | 40 | 20.9k | void * i = first_block; | 41 | 36.7k | while (i != 0) { | 42 | 15.8k | void * n = *reinterpret_cast<void **>(i); | 43 | 15.8k | free(i); | 44 | 15.8k | i = n; | 45 | 15.8k | } | 46 | 20.9k | first_block = 0; | 47 | 20.9k | first_available = 0; | 48 | 20.9k | } |
acommon::BlockSList<aspeller::Conds const*>::clear() Line | Count | Source | 39 | 2.06k | { | 40 | 2.06k | void * i = first_block; | 41 | 3.18k | while (i != 0) { | 42 | 1.11k | void * n = *reinterpret_cast<void **>(i); | 43 | 1.11k | free(i); | 44 | 1.11k | i = n; | 45 | 1.11k | } | 46 | 2.06k | first_block = 0; | 47 | 2.06k | first_available = 0; | 48 | 2.06k | } |
acommon::BlockSList<char const*>::clear() Line | Count | Source | 39 | 33.8k | { | 40 | 33.8k | void * i = first_block; | 41 | 58.9k | while (i != 0) { | 42 | 25.1k | void * n = *reinterpret_cast<void **>(i); | 43 | 25.1k | free(i); | 44 | 25.1k | i = n; | 45 | 25.1k | } | 46 | 33.8k | first_block = 0; | 47 | 33.8k | first_available = 0; | 48 | 33.8k | } |
acommon::BlockSList<std::__1::pair<char const* const, acommon::Vector<char const*> > >::clear() Line | Count | Source | 39 | 6.17k | { | 40 | 6.17k | void * i = first_block; | 41 | 9.26k | while (i != 0) { | 42 | 3.08k | void * n = *reinterpret_cast<void **>(i); | 43 | 3.08k | free(i); | 44 | 3.08k | i = n; | 45 | 3.08k | } | 46 | 6.17k | first_block = 0; | 47 | 6.17k | first_available = 0; | 48 | 6.17k | } |
|
49 | | |
50 | | } |
51 | | |
52 | | #endif |