Subversion Repositories Filer-Free

Rev

Rev 63 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 63 Rev 64
Line 3... Line 3...
3
// Redistribution and modification are permitted under the terms of the
3
// Redistribution and modification are permitted under the terms of the
4
// GNU General Public License (version 2 or any later version).
4
// GNU General Public License (version 2 or any later version).
5
 
5
 
6
#include <cstring>
6
#include <cstring>
7
#include <cstdio>
7
#include <cstdio>
-
 
8
#include <new>
8
 
9
 
9
#include "oslib/os.h"
10
#include "oslib/os.h"
10
#include "oslib/osfscontrol.h"
11
#include "oslib/osfscontrol.h"
11
 
12
 
12
#include "pathname_hash.h"
13
#include "pathname_hash.h"
Line 73... Line 74...
73
        // a memory leak of one of them fails.
74
        // a memory leak of one of them fails.
74
        if (_capacity<capacity)
75
        if (_capacity<capacity)
75
        {
76
        {
76
                // Reallocate index data (without allowing the existing index
77
                // Reallocate index data (without allowing the existing index
77
                // to become invalid until it is no longer needed).
78
                // to become invalid until it is no longer needed).
78
                int* new_index_data=new int[capacity];
79
                int* new_index_data=new(std::nothrow) int[capacity];
79
                for (unsigned int i=0;i!=_size;++i)
80
                for (unsigned int i=0;i!=_size;++i)
80
                {
81
                {
81
                        new_index_data[i]=_index_data[i];
82
                        new_index_data[i]=_index_data[i];
82
                }
83
                }
83
                volatile int* old_index_data=_index_data;
84
                volatile int* old_index_data=_index_data;
Line 85... Line 86...
85
                delete[] old_index_data;
86
                delete[] old_index_data;
86
 
87
 
87
                // Reallocate index node pointers (again, without allowing the
88
                // Reallocate index node pointers (again, without allowing the
88
                // existing node pointers to become invalid until they are no
89
                // existing node pointers to become invalid until they are no
89
                // longer needed).
90
                // longer needed).
-
 
91
                volatile node** new_index_nodes=
90
                volatile node** new_index_nodes=new volatile node*[capacity];
92
                        new(std::nothrow) volatile node*[capacity];
91
                for (unsigned int i=0;i!=_size;++i)
93
                for (unsigned int i=0;i!=_size;++i)
92
                {
94
                {
93
                        new_index_nodes[i]=_index_nodes[i];
95
                        new_index_nodes[i]=_index_nodes[i];
94
                }
96
                }
95
                volatile node** old_index_nodes=_index_nodes;
97
                volatile node** old_index_nodes=_index_nodes;
Line 97... Line 99...
97
                delete[] old_index_nodes;
99
                delete[] old_index_nodes;
98
 
100
 
99
                // Create new nodes.
101
                // Create new nodes.
100
                while (_capacity<capacity)
102
                while (_capacity<capacity)
101
                {
103
                {
102
                        node* n=new node;
104
                        node* n=new(std::nothrow) node;
103
                        n->next=_free.next;
105
                        n->next=_free.next;
104
                        _free.next=n;
106
                        _free.next=n;
105
                        ++_capacity;
107
                        ++_capacity;
106
                }
108
                }
107
        }
109
        }