File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,10 @@ RCUTILS_WARN_UNUSED
108108rcutils_allocator_t 
109109rcutils_get_default_allocator (void );
110110
111+ RCUTILS_PUBLIC 
112+ void 
113+ rcutils_set_default_allocator (rcutils_allocator_t  override_allocator );
114+ 
111115/// Return true if the given allocator has non-null function pointers. 
112116/** 
113117 * \param[in] allocator to be checked by the function 
Original file line number Diff line number Diff line change @@ -69,16 +69,31 @@ rcutils_get_zero_initialized_allocator(void)
6969  return  zero_allocator ;
7070}
7171
72+ // have the ability to override the default allocator 
73+ static  rcutils_allocator_t 
74+ rcutils_override_default_allocator ;
75+ 
76+ void 
77+ rcutils_set_default_allocator (rcutils_allocator_t  override_allocator )
78+ {
79+   if  (rcutils_allocator_is_valid (& override_allocator ))
80+     rcutils_override_default_allocator  =  override_allocator ;
81+ }
82+ 
7283rcutils_allocator_t 
7384rcutils_get_default_allocator (void )
7485{
86+   if  (rcutils_allocator_is_valid (& rcutils_override_default_allocator ))
87+     return  rcutils_override_default_allocator ;
88+ 
7589  static  rcutils_allocator_t  default_allocator  =  {
7690    .allocate  =  __default_allocate ,
7791    .deallocate  =  __default_deallocate ,
7892    .reallocate  =  __default_reallocate ,
7993    .zero_allocate  =  __default_zero_allocate ,
8094    .state  =  NULL ,
8195  };
96+ 
8297  return  default_allocator ;
8398}
8499
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments