程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> 仿SGI STL的一個allocator

仿SGI STL的一個allocator

編輯:C++入門知識

   _STL_ALLOC_H_
 
 #include <cstddef>
 #include <cstdlib>
 
       
      
                    
         inline  *         
         inline   deallocate( *      *           *result = 
         result = (*          (!             exit(-         
                    _malloc_alloc::deallocate( *        
      
                    
            ALIGN =          
            MAX_BYTES =          
            FREELIST_NUMS = MAX_BYTES /         
               union node *              client_data[  
          node *         
           *         
           *         
                        
                        (bytes + (ALIGN - )) & ~(ALIGN -           
                       
              ((bytes)+ALIGN - ) / ALIGN -           
           *                  
           *chunk_alloc(size_t bytes,  &              
          *         
           deallocate( *      _default_alloc::node *_default_alloc::free_list[FREELIST_NUMS] = 
     {, , , , , , , , , , , , , , ,       *_default_alloc::start_of_memorypool =      *_default_alloc::end_of_memorypool =      _default_alloc::heap_size =  
      *          node *result =         node **my_free_list = 
          (bytes >              
         my_free_list = free_list +         (!*               *r =                       
             result = *         *my_free_list = result->                _default_alloc::deallocate( *          node *q = (node*         node **my_free_list = 
         (n >              
         my_free_list = free_list +         q->free_list_link = *         *my_free_list =       *           nobjs =  
          *chunk =         node **my_free_list =         node *result =         node *cur, * 
         ( ==                      result = (node*         my_free_list = free_list +         next = *my_free_list = (node*)(chunk + 
         ( i = ; ;++              cur =             next = (node*)((*)next +             (nobjs -  ==                  cur->free_list_link =                               
                 cur->free_list_link =                 *_default_alloc::chunk_alloc(size_t bytes,  &           *result =         size_t total_bytes = bytes *         size_t bytes_left = end_of_memorypool - 
         (bytes_left >=              result =             start_of_memorypool +=                         (bytes_left >=              nobjs = bytes_left /             total_bytes = bytes *             result =             start_of_memorypool +=                       
              size_t bytes_to_get =  * total_bytes + ROUND_UP(heap_size >>              (bytes_left >                   node **my_free_list = free_list +                 ((node*)start_of_memorypool)->free_list_link = *                 *my_free_list = (node*              start_of_memorypool = (*             (nullptr ==                  node **my_free_list, *                  ( i = bytes; i <= MAX_BYTES; i +=                      my_free_list = free_list +                     p = *                     (nullptr !=                          *my_free_list = p->                         start_of_memorypool = (*                         end_of_memorypool = start_of_memorypool +                                            end_of_memorypool =                 start_of_memorypool = (*              heap_size +=             end_of_memorypool = start_of_memorypool +                
        
       
 
 
     template< T,  Alloc>
                    
          T *                == n ?  : (T*)Alloc::allocate(n *           
          T *               (T*)Alloc::allocate(            deallocate(T *               ( !=                 Alloc::deallocate(ptr, n *             deallocate(T *              Alloc::deallocate(ptr,    }
 
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved