Ticket #1433: pespacket_block_allocation.patch
| File pespacket_block_allocation.patch, 1.9 KB (added by , 20 years ago) |
|---|
-
libs/libmythtv/mpeg/pespacket.cpp
135 135 static vector<unsigned char*> free4096; 136 136 static map<unsigned char*, bool> alloc4096; 137 137 138 #define BLOCKS188 1000138 #define BLOCKS188 512 139 139 static unsigned char* get_188_block() 140 140 { 141 if ( !free188.size())141 if (free188.empty()) 142 142 { 143 143 mem188.push_back((unsigned char*) malloc(188 * BLOCKS188)); 144 144 free188.reserve(BLOCKS188); 145 unsigned char* block_start = mem188.back(); 145 146 for (uint i = 0; i < BLOCKS188; ++i) 146 free188.push_back(i*188 + mem188.back());147 free188.push_back(i*188 + block_start); 147 148 } 148 149 149 150 unsigned char *ptr = free188.back(); … … 163 164 alloc188.erase(ptr); 164 165 if (alloc188.size()) 165 166 free188.push_back(ptr); 166 else 167 // free the allocator only if more than 1 block was used 168 else if (mem188.size() > 1) 167 169 { 168 170 vector<unsigned char*>::iterator it; 169 171 for (it = mem188.begin(); it != mem188.end(); ++it) … … 174 176 } 175 177 } 176 178 177 #define BLOCKS4096 256179 #define BLOCKS4096 128 178 180 static unsigned char* get_4096_block() 179 181 { 180 if ( !free4096.size())182 if (free4096.empty()) 181 183 { 182 184 mem4096.push_back((unsigned char*) malloc(4096 * BLOCKS4096)); 183 185 free4096.reserve(BLOCKS4096); 186 unsigned char* block_start = mem4096.back(); 184 187 for (uint i = 0; i < BLOCKS4096; ++i) 185 free4096.push_back(i*4096 + mem4096.back());188 free4096.push_back(i*4096 + block_start); 186 189 } 187 190 188 191 unsigned char *ptr = free4096.back(); … … 221 224 } 222 225 #endif 223 226 } 224 else 227 // free the allocator only if more than 1 block was used 228 else if (mem4096.size() > 1) 225 229 { 226 230 vector<unsigned char*>::iterator it; 227 231 for (it = mem4096.begin(); it != mem4096.end(); ++it)
