00001 /** @file 00002 00003 Implementation of the proxy allocators. 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 */ 00023 #include "I_EventSystem.h" 00024 00025 int thread_freelist_size = 512; 00026 00027 void* 00028 thread_alloc(Allocator &a, ProxyAllocator &l) 00029 { 00030 #if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST 00031 if (l.freelist) { 00032 void *v = (void *) l.freelist; 00033 l.freelist = *(void **) l.freelist; 00034 l.allocated--; 00035 return v; 00036 } 00037 #else 00038 (void)l; 00039 #endif 00040 return a.alloc_void(); 00041 } 00042 00043 void 00044 thread_freeup(Allocator &a, ProxyAllocator &l) 00045 { 00046 while (l.freelist) { 00047 void *v = (void *) l.freelist; 00048 l.freelist = *(void **) l.freelist; 00049 l.allocated--; 00050 a.free_void(v); // we could use a bulk free here 00051 } 00052 ink_assert(!l.allocated); 00053 }