rpc_sessionpool* rpc_sessionpool_new() { rpc_sessionpool *pool = rpc_new(rpc_sessionpool,1); pthread_mutex_init(&pool->mutex, NULL); pool->data = rpc_new0(pointer,POOLCAPACITY); pool->size = POOLCAPACITY; return pool; }
rpc_array* rpc_array_new_size(int size) { rpc_array *array = rpc_new(rpc_array,1); pthread_mutex_init(&array->lock, NULL); array->data = rpc_new0(pointer,size ); array->size = size; array->cur = 0; return array; }
rpc_async_queue* rpc_async_queue_new() { rpc_async_queue *queue = rpc_new(rpc_async_queue,1); pthread_mutex_init(&queue->mutex, NULL); pthread_cond_init(&queue->cond, NULL); queue->head = NULL; queue->tail = NULL; return queue; }
rpc_thread* rpc_thread_new(rpc_thread_func func) { rpc_thread *th = rpc_new(rpc_thread,1); th->func = func; pthread_t pid; if (pthread_create(&pid, NULL, rpc_thread_inner, th) == -1) { //go to rpc_free(th); return NULL; } th->pid = pid; th->finished = TRUE; return th; }
rpc_response* rpc_response_new() { if (rpc_response_freelist == NULL) { pthread_mutex_lock(&freelock); if (rpc_response_freelist == NULL) { rpc_response_freelist = rpc_array_new(); } pthread_mutex_unlock(&freelock); } //rpc_response *rsp = g_new(rpc_response,1); rpc_response *rsp = (rpc_response*) rpc_array_get(rpc_response_freelist); if (rsp == NULL) { rsp = rpc_new(rpc_response,1); } return rsp; }
rpc_request* rpc_request_new() { if (rpc_request_freelist == NULL) { pthread_mutex_lock(&freelock); if (rpc_request_freelist == NULL) { rpc_request_freelist = rpc_array_new(); } pthread_mutex_unlock(&freelock); } //rpc_request *req = g_new(rpc_request,1); rpc_request *req = (rpc_request*) rpc_array_get(rpc_request_freelist); if (req == NULL) { req = rpc_new(rpc_request,1); } return req; }
static int connectWin(rdWin *w, char *filename) { int fd; assert(w); if (filename == 0) filename = "New"; if (rpc_new(wilyq, &w->id, filename, false) < 0) { DPRINT("Could not get new window from wily"); freeWin(w); return -1; } return 0; }
rdpTsg* tsg_new(rdpTransport* transport) { rdpTsg* tsg; tsg = (rdpTsg*) malloc(sizeof(rdpTsg)); ZeroMemory(tsg, sizeof(rdpTsg)); if (tsg != NULL) { tsg->transport = transport; tsg->settings = transport->settings; tsg->rpc = rpc_new(tsg->transport); tsg->PendingPdu = FALSE; } return tsg; }
rdpTsg* tsg_new(rdpTransport* transport) { rdpTsg* tsg; tsg = (rdpTsg*) calloc(1, sizeof(rdpTsg)); if (!tsg) return NULL; tsg->transport = transport; tsg->settings = transport->settings; tsg->rpc = rpc_new(tsg->transport); if (!tsg->rpc) goto out_free; tsg->PendingPdu = FALSE; return tsg; out_free: free(tsg); return NULL; }