static void* evport_init(struct event_base *base) { struct evport_data *evpd; int i; if (!(evpd = mm_calloc(1, sizeof(struct evport_data)))) return (NULL); if ((evpd->ed_port = port_create()) == -1) { mm_free(evpd); return (NULL); } /* * Initialize file descriptor structure */ evpd->ed_fds = mm_calloc(DEFAULT_NFDS, sizeof(struct fd_info)); if (evpd->ed_fds == NULL) { close(evpd->ed_port); mm_free(evpd); return (NULL); } evpd->ed_nevents = DEFAULT_NFDS; for (i = 0; i < EVENTS_PER_GETN; i++) evpd->ed_pending[i] = -1; evsig_init(base); return (evpd); }
/************************************************************************ * See .h file for description. ************************************************************************/ MHMM_T* allocate_mhmm(ALPH_T* alph, int num_states) { /* First allocate the struct itself. */ MHMM_T* an_mhmm = (MHMM_T*) mm_calloc(1, sizeof(MHMM_T)); /* Then allocate the states. */ an_mhmm->states = (MHMM_STATE_T *) mm_calloc(num_states, sizeof(MHMM_STATE_T)); an_mhmm->num_states = num_states; /* ... and the transition matrix. */ an_mhmm->trans = allocate_matrix(num_states, num_states); /* Allocate the alphabet. */ an_mhmm->alph = alph_hold(alph); // Allocate the background distribution. an_mhmm->background = allocate_array(alph_size_full(an_mhmm->alph)); // Set other stuff to NULL. an_mhmm->description = NULL; an_mhmm->motif_file = NULL; an_mhmm->sequence_file = NULL; an_mhmm->hot_states = NULL; an_mhmm->num_hot_states = 0; return an_mhmm; }
static void * kq_init(struct event_base *base) { int kq = -1; struct kqop *kqueueop = NULL; if (!(kqueueop = mm_calloc(1, sizeof(struct kqop)))) return (NULL); /* Initialize the kernel queue */ if ((kq = kqueue()) == -1) { event_warn("kqueue"); goto err; } kqueueop->kq = kq; kqueueop->pid = getpid(); /* Initialize fields */ kqueueop->changes = mm_calloc(NEVENT, sizeof(struct kevent)); if (kqueueop->changes == NULL) goto err; kqueueop->events = mm_calloc(NEVENT, sizeof(struct kevent)); if (kqueueop->events == NULL) goto err; kqueueop->events_size = kqueueop->changes_size = NEVENT; /* Check for Mac OS X kqueue bug. */ memset(&kqueueop->changes[0], 0, sizeof kqueueop->changes[0]); kqueueop->changes[0].ident = -1; kqueueop->changes[0].filter = EVFILT_READ; kqueueop->changes[0].flags = EV_ADD; /* * If kqueue works, then kevent will succeed, and it will * stick an error in events[0]. If kqueue is broken, then * kevent will fail. */ if (kevent(kq, kqueueop->changes, 1, kqueueop->events, NEVENT, NULL) != 1 || kqueueop->events[0].ident != -1 || kqueueop->events[0].flags != EV_ERROR) { event_warn("%s: detected broken kqueue; not using.", __func__); goto err; } base->evsigsel = &kqsigops; base->evsigbase = kqueueop; return (kqueueop); err: if (kqueueop) kqop_free(kqueueop); return (NULL); }
struct event_iocp_port * event_iocp_port_launch(int n_cpus) { struct event_iocp_port *port; int i; if (!extension_fns_initialized) init_extension_functions(&the_extension_fns); if (!(port = mm_calloc(1, sizeof(struct event_iocp_port)))) return NULL; if (n_cpus <= 0) n_cpus = N_CPUS_DEFAULT; port->n_threads = n_cpus * 2; port->threads = mm_calloc(port->n_threads, sizeof(HANDLE)); if (!port->threads) goto err; port->port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, n_cpus); port->ms = -1; if (!port->port) goto err; port->shutdownSemaphore = CreateSemaphore(NULL, 0, 1, NULL); if (!port->shutdownSemaphore) goto err; for (i=0; i<port->n_threads; ++i) { ev_uintptr_t th = _beginthread(loop, 0, port); if (th == (ev_uintptr_t)-1) goto err; port->threads[i] = (HANDLE)th; ++port->n_live_threads; } InitializeCriticalSectionAndSpinCount(&port->lock, 1000); return port; err: if (port->port) CloseHandle(port->port); if (port->threads) mm_free(port->threads); if (port->shutdownSemaphore) CloseHandle(port->shutdownSemaphore); mm_free(port); return NULL; }
static void* evport_init(struct event_base *base) { struct evport_data *evpd; if (!(evpd = mm_calloc(1, sizeof(struct evport_data)))) return (NULL); if ((evpd->ed_port = port_create()) == -1) { mm_free(evpd); return (NULL); } if (grow(evpd, INITIAL_EVENTS_PER_GETN) < 0) { close(evpd->ed_port); mm_free(evpd); return NULL; } evpd->ed_npending = 0; evsig_init_(base); return (evpd); }
struct bufferevent * bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options) { struct bufferevent_private *bufev_p; struct bufferevent *bufev; #ifdef _WIN32 if (base && event_base_get_iocp_(base)) return bufferevent_async_new_(base, fd, options); #endif if ((bufev_p = mm_calloc(1, sizeof(struct bufferevent_private)))== NULL) return NULL; if (bufferevent_init_common_(bufev_p, base, &bufferevent_ops_socket, options) < 0) { mm_free(bufev_p); return NULL; } bufev = &bufev_p->bev; evbuffer_set_flags(bufev->output, EVBUFFER_FLAG_DRAINS_TO_FD); event_assign(&bufev->ev_read, bufev->ev_base, fd, EV_READ|EV_PERSIST, bufferevent_readcb, bufev); event_assign(&bufev->ev_write, bufev->ev_base, fd, EV_WRITE|EV_PERSIST, bufferevent_writecb, bufev); evbuffer_add_cb(bufev->output, bufferevent_socket_outbuf_cb, bufev); evbuffer_freeze(bufev->input, 0); evbuffer_freeze(bufev->output, 1); return bufev; }
static void hash_split(ps_mm *data) { php_uint32 nmax; ps_sd **nhash; ps_sd **ohash, **ehash; ps_sd *ps, *next; nmax = ((data->hash_max + 1) << 1) - 1; nhash = mm_calloc(data->mm, nmax + 1, sizeof(*data->hash)); if (!nhash) { /* no further memory to expand hash table */ return; } ehash = data->hash + data->hash_max + 1; for (ohash = data->hash; ohash < ehash; ohash++) { for (ps = *ohash; ps; ps = next) { next = ps->next; ps->next = nhash[ps->hv & nmax]; nhash[ps->hv & nmax] = ps; } } mm_free(data->mm, data->hash); data->hash = nhash; data->hash_max = nmax; }
static void *meta_calloc(size_t nelem, size_t size) { void *ret=mm_calloc(nelem,size); if (memInit) CmiPrintf("CMI_MEMORY(%d)> calloc(%d,%d) => %p\n", CmiMyPe(),nelem,size,ret); return ret; }
/********************************************************************** shuffle_sequence() shuffle a given sequences based on their content **********************************************************************/ void shuffle_sequence( SEQ_T* seq, /* original sequence IN */ unsigned int seed, /* seed IN */ SEQ_T** target /* target sequence OUT */ ){ my_srand(seed); assert(*target==NULL); // reset target if not null if (*target != NULL){ free_seq(*target); } *target = allocate_seq(get_seq_name(seq),"shuffled",get_seq_offset(seq),get_raw_sequence(seq)); char *raw = get_raw_sequence(*target); /* copy original in temp string */ char* tmp = (char*)mm_calloc(get_seq_length(seq)+1,sizeof(char)); strcpy(tmp,get_raw_sequence(seq)); tmp[get_seq_length(seq)]='\0'; int i,j; char *ss; char *dd; for(j=0,i=get_seq_length(seq);i>0;i--){ // Pick a random number in the range: int pick = rand() % i; raw[j++] = tmp[pick]; // "shift" routine here eliminates the "picked" base from the _src string: // dd starts at the picked position: ss is one beyond that: for( dd = tmp+pick , ss = dd + 1 ; *dd ; *dd++=*ss++ ); } myfree(tmp); }
void * evrpc_add_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type, int (*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), void *cb_arg) { struct _evrpc_hooks *base = vbase; struct evrpc_hook_list *head = NULL; struct evrpc_hook *hook = NULL; switch (hook_type) { case EVRPC_INPUT: head = &base->in_hooks; break; case EVRPC_OUTPUT: head = &base->out_hooks; break; default: EVUTIL_ASSERT(hook_type == EVRPC_INPUT || hook_type == EVRPC_OUTPUT); } hook = mm_calloc(1, sizeof(struct evrpc_hook)); EVUTIL_ASSERT(hook != NULL); hook->process = cb; hook->process_arg = cb_arg; TAILQ_INSERT_TAIL(head, hook, next); return (hook); }
static struct accepting_socket * new_accepting_socket(struct evconnlistener_iocp *lev, int family) { struct accepting_socket *res; int addrlen; int buflen; if (family == AF_INET) addrlen = sizeof(struct sockaddr_in); else if (family == AF_INET6) addrlen = sizeof(struct sockaddr_in6); else return NULL; buflen = (addrlen+16)*2; res = mm_calloc(1,sizeof(struct accepting_socket)-1+buflen); if (!res) return NULL; event_overlapped_init(&res->overlapped, accepted_socket_cb); res->s = INVALID_SOCKET; res->lev = lev; res->buflen = buflen; res->family = family; event_deferred_cb_init(&res->deferred, accepted_socket_invoke_user_cb, res); InitializeCriticalSectionAndSpinCount(&res->lock, 1000); return res; }
/*********************************************************************** * Allocate one array. ***********************************************************************/ ARRAY_T* allocate_array (const int num_items) { ARRAY_T* new_array = (ARRAY_T*)mm_malloc(sizeof(ARRAY_T)); new_array->items = (ATYPE*)mm_calloc(num_items, sizeof(ATYPE)); new_array->num_items = num_items; return(new_array); }
static void * epoll_init(struct event_base *base) { int epfd = -1; struct epollop *epollop; #ifdef _EVENT_HAVE_EPOLL_CREATE1 /* First, try the shiny new epoll_create1 interface, if we have it. */ epfd = epoll_create1(EPOLL_CLOEXEC); #endif if (epfd == -1) { /* Initialize the kernel queue using the old interface. (The size field is ignored since 2.6.8.) */ if ((epfd = epoll_create(32000)) == -1) { if (errno != ENOSYS) event_warn("epoll_create"); return (NULL); } evutil_make_socket_closeonexec(epfd); } if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) { close(epfd); return (NULL); } epollop->epfd = epfd; /* Initialize fields */ epollop->events = mm_calloc(INITIAL_NEVENT, sizeof(struct epoll_event)); if (epollop->events == NULL) { mm_free(epollop); close(epfd); return (NULL); } epollop->nevents = INITIAL_NEVENT; if ((base->flags & EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST) != 0 || ((base->flags & EVENT_BASE_FLAG_IGNORE_ENV) == 0 && evutil_getenv("EVENT_EPOLL_USE_CHANGELIST") != NULL)) base->evsel = &epollops_changelist; evsig_init(base); return (epollop); }
static void * devpoll_init(struct event_base *base) { int dpfd, nfiles = NEVENT; struct rlimit rl; struct devpollop *devpollop; if (!(devpollop = mm_calloc(1, sizeof(struct devpollop)))) return (NULL); if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) nfiles = rl.rlim_cur; /* Initialize the kernel queue */ if ((dpfd = open("/dev/poll", O_RDWR)) == -1) { event_warn("open: /dev/poll"); mm_free(devpollop); return (NULL); } devpollop->dpfd = dpfd; /* Initialize fields */ /* FIXME: allocating 'nfiles' worth of space here can be * expensive and unnecessary. See how epoll.c does it instead. */ devpollop->events = mm_calloc(nfiles, sizeof(struct pollfd)); if (devpollop->events == NULL) { mm_free(devpollop); close(dpfd); return (NULL); } devpollop->nevents = nfiles; devpollop->changes = mm_calloc(nfiles, sizeof(struct pollfd)); if (devpollop->changes == NULL) { mm_free(devpollop->events); mm_free(devpollop); close(dpfd); return (NULL); } evsig_init(base); return (devpollop); }
static void * devpoll_init(struct event_base *base) { int dpfd, nfiles = NEVENT; struct rlimit rl; struct devpollop *devpollop; if (!(devpollop = mm_calloc(1, sizeof(struct devpollop)))) return (NULL); if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY) nfiles = rl.rlim_cur; /* Initialize the kernel queue */ if ((dpfd = open("/dev/poll", O_RDWR)) == -1) { event_warn("open: /dev/poll"); mm_free(devpollop); return (NULL); } devpollop->dpfd = dpfd; /* Initialize fields */ devpollop->events = mm_calloc(nfiles, sizeof(struct pollfd)); if (devpollop->events == NULL) { mm_free(devpollop); close(dpfd); return (NULL); } devpollop->nevents = nfiles; devpollop->changes = mm_calloc(nfiles, sizeof(struct pollfd)); if (devpollop->changes == NULL) { mm_free(devpollop->events); mm_free(devpollop); close(dpfd); return (NULL); } evsig_init(base); return (devpollop); }
struct bufferevent * bufferevent_async_new(struct event_base *base, evutil_socket_t fd, int options) { struct bufferevent_async *bev_a; struct bufferevent *bev; struct event_iocp_port *iocp; options |= BEV_OPT_THREADSAFE; if (!(iocp = event_base_get_iocp(base))) return NULL; if (fd >= 0 && event_iocp_port_associate(iocp, fd, 1)<0) { int err = GetLastError(); /* We may have alrady associated this fd with a port. * Let's hope it's this port, and that the error code * for doing this neer changes. */ if (err != ERROR_INVALID_PARAMETER) return NULL; } if (!(bev_a = mm_calloc(1, sizeof(struct bufferevent_async)))) return NULL; bev = &bev_a->bev.bev; if (!(bev->input = evbuffer_overlapped_new(fd))) { mm_free(bev_a); return NULL; } if (!(bev->output = evbuffer_overlapped_new(fd))) { evbuffer_free(bev->input); mm_free(bev_a); return NULL; } if (bufferevent_init_common(&bev_a->bev, base, &bufferevent_ops_async, options)<0) goto err; evbuffer_add_cb(bev->input, be_async_inbuf_callback, bev); evbuffer_add_cb(bev->output, be_async_outbuf_callback, bev); event_overlapped_init(&bev_a->connect_overlapped, connect_complete); event_overlapped_init(&bev_a->read_overlapped, read_complete); event_overlapped_init(&bev_a->write_overlapped, write_complete); bev_a->ok = fd >= 0; if (bev_a->ok) _bufferevent_init_generic_timeout_cbs(bev); return bev; err: bufferevent_free(&bev_a->bev.bev); return NULL; }
MM_Hash *mm_hash_new(MM *mm, MM_HashDtor dtor) { MM_Hash *table; table = (MM_Hash *) mm_calloc(mm, 1, sizeof(MM_Hash)); table->mm = mm; table->dtor = dtor; return table; }
/**************************************************************************** * Copy a string, with allocation. ****************************************************************************/ void copy_string (char** target, const char* source) { if (source == NULL) { *target = NULL; } else { *target = (char *)mm_calloc(strlen(source) + 1, sizeof(char)); strcpy(*target, source); } }
static void * epoll_init(struct event_base *base) { int epfd; struct epollop *epollop; /* Initialize the kernel queue. (The size field is ignored since * 2.6.8.) */ if ((epfd = epoll_create(32000)) == -1) { if (errno != ENOSYS) event_warn("epoll_create"); return (NULL); } evutil_make_socket_closeonexec(epfd); if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) { close(epfd); return (NULL); } epollop->epfd = epfd; /* Initialize fields */ epollop->events = mm_calloc(INITIAL_NEVENT, sizeof(struct epoll_event)); if (epollop->events == NULL) { mm_free(epollop); close(epfd); return (NULL); } epollop->nevents = INITIAL_NEVENT; if ((base->flags & EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST) != 0 || ((base->flags & EVENT_BASE_FLAG_IGNORE_ENV) == 0 && evutil_getenv("EVENT_EPOLL_USE_CHANGELIST") != NULL)) base->evsel = &epollops_changelist; evsig_init(base); return (epollop); }
struct evconnlistener * evconnlistener_new(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, evutil_socket_t fd) { struct evconnlistener_event *lev; #ifdef _WIN32 if (base && event_base_get_iocp_(base)) { const struct win32_extension_fns *ext = event_get_win32_extension_fns_(); if (ext->AcceptEx && ext->GetAcceptExSockaddrs) return evconnlistener_new_async(base, cb, ptr, flags, backlog, fd); } #endif if (backlog > 0) { if (listen(fd, backlog) < 0) return NULL; } else if (backlog < 0) { if (listen(fd, 128) < 0) return NULL; } lev = (struct evconnlistener_event *)mm_calloc(1, sizeof(struct evconnlistener_event)); if (!lev) return NULL; lev->base.ops = &evconnlistener_event_ops; lev->base.cb = cb; lev->base.user_data = ptr; lev->base.flags = flags; lev->base.refcnt = 1; lev->base.accept4_flags = 0; if (!(flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING)) lev->base.accept4_flags |= EVUTIL_SOCK_NONBLOCK; if (flags & LEV_OPT_CLOSE_ON_EXEC) lev->base.accept4_flags |= EVUTIL_SOCK_CLOEXEC; if (flags & LEV_OPT_THREADSAFE) { EVTHREAD_ALLOC_LOCK(lev->base.lock, EVTHREAD_LOCKTYPE_RECURSIVE); } event_assign(&lev->listener, base, fd, EV_READ|EV_PERSIST, listener_read_cb, lev); if (!(flags & LEV_OPT_DISABLED)) evconnlistener_enable(&lev->base); return &lev->base; }
static void * poll_init(struct event_base *base) { struct pollop *pollop; if (!(pollop = mm_calloc(1, sizeof(struct pollop)))) return (NULL); evsig_init(base); return (pollop); }
void remove_flanking_xs (SEQ_T* sequence) { char* new_seq; // Copy of the sequence. new_seq = (char*)mm_calloc(sequence->length - 1, sizeof(char)); strncpy(new_seq, &(sequence->sequence[1]), sequence->length - 2); new_seq[sequence->length - 2] = '\0'; myfree(sequence->sequence); sequence->sequence = new_seq; sequence->length -= 2; }
struct bufferevent * bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options) { struct bufferevent_private *bufev_p; struct bufferevent *bufev; #ifdef WIN32 if (base && event_base_get_iocp(base)) return bufferevent_async_new(base, fd, options); #endif if ((bufev_p = mm_calloc(1, sizeof(struct bufferevent_private)))== NULL) return NULL; if (bufferevent_init_common(bufev_p, base, &bufferevent_ops_socket, options) < 0) { mm_free(bufev_p); return NULL; } bufev = &bufev_p->bev; //设置将evbuffer的数据向fd传 evbuffer_set_flags(bufev->output, EVBUFFER_FLAG_DRAINS_TO_FD); //设置读写回调 event_assign(&bufev->ev_read, bufev->ev_base, fd, EV_READ|EV_PERSIST, bufferevent_readcb, bufev); event_assign(&bufev->ev_write, bufev->ev_base, fd, EV_WRITE|EV_PERSIST, bufferevent_writecb, bufev); //设置evbuffer的回调函数,使得外界给写缓冲区添加数据时,能触发 //写操作,这个回调对于写事件的监听是很重要的 evbuffer_add_cb(bufev->output, bufferevent_socket_outbuf_cb, bufev); /* 虽然这里冻结了,但实际上Libevent在读数据或者写数据之前会解冻的读完或者写完数据后,又会马上冻结。 * 这主要防止数据被意外修改。用户一般不会直接调用evbuffer_freeze或者evbuffer_unfreeze函数。 * 一切的冻结和解冻操作都由Libevent内部完成。还有一点要注意,因为这里只是把写缓冲区的头部冻结了。 * 所以还是可以往写缓冲区的尾部追加数据。同样,此时也是可以从读缓冲区读取数据。这个是必须的。 * 因为在Libevent内部不解冻的时候,用户需要从读缓冲区中获取数据(这相当于从socket fd中读取数据), * 用户也需要把数据写到写缓冲区中(这相当于把数据写入到socket fd中)。*/ //冻结读缓冲区的尾部,未解冻之前不能往读缓冲区追加数据 //也就是说不能从socket fd中读取数据 evbuffer_freeze(bufev->input, 0); //冻结写缓冲区的头部,未解冻之前不能把写缓冲区的头部数据删除 //也就是说不能把数据写到socket fd evbuffer_freeze(bufev->output, 1); return bufev; }
static void * poll_init(struct event_base *base) { struct pollop *pollop; if (!(pollop = mm_calloc(1, sizeof(struct pollop)))) return (NULL); evsig_init_(base); evutil_weakrand_seed_(&base->weakrand_seed, 0); return (pollop); }
static void * select_init(struct event_base *base) { struct selectop *sop; if (!(sop = mm_calloc(1, sizeof(struct selectop)))) return (NULL); select_resize(sop, howmany(32 + 1, NFDBITS)*sizeof(fd_mask)); evsig_init(base); return (sop); }
struct evbuffer * evbuffer_overlapped_new(evutil_socket_t fd) { struct evbuffer_overlapped *evo; evo = mm_calloc(1, sizeof(struct evbuffer_overlapped)); TAILQ_INIT(&evo->buffer.callbacks); evo->buffer.refcnt = 1; evo->buffer.is_overlapped = 1; evo->fd = fd; return &evo->buffer; }
FAR void *calloc(size_t n, size_t elem_size) { #ifdef CONFIG_MM_MULTIHEAP return mm_calloc(&g_mmheap, n, elem_size); #else FAR void *ret = NULL; if (n > 0 && elem_size > 0) { ret = zalloc(n * elem_size); } return ret; #endif }
/*************************************************************************** * Add or remove Xs from either side of the sequence. ***************************************************************************/ static void add_flanking_xs (SEQ_T* sequence, ALPH_T alph) { char* new_seq = NULL; // Pointer to copy of the sequence. new_seq = (char*)mm_calloc(sequence->length + 3, sizeof(char)); strcpy(&(new_seq[1]), sequence->sequence); new_seq[0] = alph_wildcard(alph); new_seq[sequence->length + 1] = alph_wildcard(alph); new_seq[sequence->length + 2] = '\0'; myfree(sequence->sequence); sequence->sequence = new_seq; sequence->length += 2; }
/*********************************************************************** * Say that the motif ID is printed centered above a given motif. * If the motif ID string is longer than the motif, we truncate * it on the right and align the first character over the start of * the motif. * This function returns the character that appears in the nth * position of that motif ID string. * If the motif was created from a double stranded source then * include the strand. ***********************************************************************/ static char get_motif_id_char (int position, MOTIF_T* a_motif) { char* motif_id_string, *id; int id_width, m_width, id_start; char return_char; assert(position < get_motif_length(a_motif)); id = get_full_motif_id(a_motif); id_width = strlen(id); m_width = get_motif_length(a_motif); // Allocate the string. motif_id_string = mm_calloc(sizeof(char), m_width + 1); // Get position where ID starts relative to start of motif. id_start = id_width <= m_width ? ((m_width - id_width) / 2) : 0; // FIXME: (tlb) The following if() was put in to make the smoke tests of mhmm // pass. It should be removed and the smoke test comparison files changed. if (m_width % 2 == 0 && id_width % 2 == 0) { id_start++; } else { id_start+=2; } // Create the centered ID string. sprintf(motif_id_string, "%*.*s%-*.*s", id_start, id_start, "", m_width-id_start, m_width-id_start, id); assert((int)(strlen(motif_id_string)) == m_width); // Get the nth character. return_char = motif_id_string[position]; if (return_char == ' ') { if ((position == 0) || (position == (m_width - 1))) { return_char = '*'; } else { return_char = '_'; } } // Free up memory and return. myfree(motif_id_string); return(return_char); }
struct evbuffer * evbuffer_overlapped_new_(evutil_socket_t fd) { struct evbuffer_overlapped *evo; evo = mm_calloc(1, sizeof(struct evbuffer_overlapped)); if (!evo) return NULL; LIST_INIT(&evo->buffer.callbacks); evo->buffer.refcnt = 1; evo->buffer.last_with_datap = &evo->buffer.first; evo->buffer.is_overlapped = 1; evo->fd = fd; return &evo->buffer; }