void rpc_ss_enable_allocate ( void ) { rpc_ss_mem_handle *p_mem_handle; rpc_ss_thread_support_ptrs_t *p_thread_support_ptrs; /* Make sure there is a thread context key */ #ifndef MEMORY_NOT_WRITTEN_SERIALLY if ( ! rpc_ss_allocate_is_set_up ) #endif rpc_ss_init_allocate_once(); /* Set up the parts of the required data structure */ p_mem_handle = (rpc_ss_mem_handle *)malloc(sizeof(rpc_ss_mem_handle)); if (p_mem_handle == NULL) { DCETHREAD_RAISE( rpc_x_no_memory ); } p_mem_handle->memory = NULL; p_mem_handle->node_table = NULL; p_thread_support_ptrs = (rpc_ss_thread_support_ptrs_t *) malloc(sizeof(rpc_ss_thread_support_ptrs_t)); if (p_thread_support_ptrs == NULL) { DCETHREAD_RAISE( rpc_x_no_memory ); } /* Complete the data structure and associate it with the key */ /* This will make rpc_ss_allocate, rpc_ss_free the allocate/free pair */ rpc_ss_build_indirection_struct( p_thread_support_ptrs, p_mem_handle, idl_true ); }
static void rpc_ss_client_get_thread_ctx ( rpc_ss_thread_support_ptrs_t **p_p_support_ptrs ) { rpc_ss_thread_support_ptrs_t *p_support_ptrs; rpc_ss_thread_indirection_t *thread_indirection_ptr; #ifndef MEMORY_NOT_WRITTEN_SERIALLY if ( ! rpc_ss_allocate_is_set_up ) #endif rpc_ss_init_allocate_once(); p_support_ptrs = (rpc_ss_thread_support_ptrs_t *)rpc_ss_get_thread_handle(); if (p_support_ptrs == NULL) { /* We have no context. Make one with the fields we need */ p_support_ptrs = (rpc_ss_thread_support_ptrs_t *) malloc(sizeof(rpc_ss_thread_support_ptrs_t)); if (p_support_ptrs == NULL) { DCETHREAD_RAISE( rpc_x_no_memory ); } p_support_ptrs->p_mem_h = (rpc_ss_mem_handle *) malloc(sizeof(rpc_ss_mem_handle)); if (p_support_ptrs->p_mem_h == NULL) { DCETHREAD_RAISE( rpc_x_no_memory ); } p_support_ptrs->p_mem_h->memory = NULL; p_support_ptrs->p_mem_h->node_table = NULL; RPC_SS_THREADS_MUTEX_CREATE (&(p_support_ptrs->mutex)); p_support_ptrs->p_allocate = (idl_void_p_t (*)( idl_size_t size ))rpc_ss_client_default_malloc; p_support_ptrs->p_free = (void (*)( idl_void_p_t ptr ))free; thread_indirection_ptr = (rpc_ss_thread_indirection_t *) malloc(sizeof(rpc_ss_thread_indirection_t)); if (thread_indirection_ptr == NULL) { DCETHREAD_RAISE( rpc_x_no_memory ); } thread_indirection_ptr->indirection = p_support_ptrs; thread_indirection_ptr->free_referents = idl_true; RPC_SS_THREADS_KEY_SET_CONTEXT( rpc_ss_thread_supp_key, thread_indirection_ptr ); } *p_p_support_ptrs = p_support_ptrs; }