Example #1
0
void collect_particles(struct PList * p)
{
  LINKLIST ll;
  make_linklist(&ll, Particles.nP, 50, Particles.Pos, GetArrPos, 0);
  p->np=Particles.nP;
  p->PIndex=linklist_search_sphere(&ll, 500./LUNIT, CoM, &p->np);
  printf("Found %d particles\n", p->np);
  free_linklist(&ll);
}
Example #2
0
int main()
{
	LinkNode *list = NULL;
	int i;
	int n, base;
	
	scanf("%d%d", &n, &base);	
	list = creat_linknode(1);
	for(i = n; i > 1 ; i --)	
		insert_linklist(list, i);
	show_linklist(list);
	list = joseph(list, base);
	show_linklist(list);
	free_linklist(list);
	return 0;
}
Example #3
0
/**
 * Free the context 
 */
void free_context(rscntxt_t *cntxt)
{
	if (NULL != cntxt) {
		if (NULL != cntxt->conn_list) {
			free_linklist(cntxt->conn_list);
			cntxt->conn_list = NULL;
		}

		if (epoll_ctl(
					cntxt->fd_epoll, 
					EPOLL_CTL_DEL, 
					cntxt->fd_srvr, 
					NULL) < 0) {
			LogE("Failed del fd_srvr from epoll");
		}

		close(cntxt->fd_srvr);
		close(cntxt->fd_epoll);

		free (cntxt);
		cntxt = NULL;
	}
}