コード例 #1
0
ファイル: axfr.c プロジェクト: jkadlec/knot-dns-zoneapi
static void axfr_query_cleanup(struct query_data *qdata)
{
	struct axfr_proc *axfr = (struct axfr_proc *)qdata->ext;

	hattrie_iter_free(axfr->i);
	ptrlist_free(&axfr->proc.nodes, qdata->mm);
	mm_free(qdata->mm, axfr);

	/* Allow zone changes (finished). */
	rcu_read_unlock();
}
コード例 #2
0
ファイル: RTADVSocket.c プロジェクト: carriercomm/osx-2
STATIC void
RTADVSocketReceiveDataInit(RTADVSocketReceiveDataRef data_p,
			   const struct in6_addr * router_p,
			   const struct nd_router_advert * ndra_p, int n)
{
    ptrlist_t			options;

    data_p->router = *router_p;
    data_p->managed_bit 
	= (ndra_p->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) != 0;
    data_p->other_bit
	= (ndra_p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER) != 0;

    /* find the DNS options */
    parse_nd_options(&options, (char *)(ndra_p + 1), n - sizeof(*ndra_p));
#ifdef DEBUG
    print_nd_options(&options);
#endif /* DEBUG */
    data_p->dns_servers = find_rdnss(&options, &data_p->dns_servers_count);
    data_p->router_hwaddr
	= find_source_link_address(&options, &data_p->router_hwaddr_len);
    ptrlist_free(&options);
    return;
}
コード例 #3
0
ファイル: RTADVSocket.c プロジェクト: carriercomm/osx-2
STATIC void
parse_nd_options(ptrlist_t * options_p, const char * buf, int len)
{
    int				left = len;
    const struct nd_opt_hdr *	opt;
    int				opt_len = 0;
    const char *		scan;

    ptrlist_init(options_p);
    
    for (scan = buf; left >= sizeof(*opt); ) {
	opt = (struct nd_opt_hdr *)scan;
	opt_len = opt->nd_opt_len * ND_OPT_ALIGN;
	if (opt_len > left) {
	    /* truncated packet */
	    ptrlist_free(options_p);
	    break;
	}
	ptrlist_add(options_p, (void *)opt);
	scan += opt_len;
	left -= opt_len;
    }
    return;
}
コード例 #4
0
ファイル: cargo.c プロジェクト: andbof/yastg
void cargo_free(struct cargo *cargo)
{
	ptrlist_free(&cargo->requires);
}
コード例 #5
0
void
dhcpol_free(dhcpol_t * list)
{
    ptrlist_free((ptrlist_t *)list);
}
コード例 #6
0
ファイル: constellation.c プロジェクト: neg/yastg
int addconstellation(char* cname)
{
    unsigned long nums, numc, i;
    char *string;
    struct sector *fs, *s;
    struct ptrlist work;
    double phi;
    unsigned long r;

    string = malloc(strlen(cname)+GREEK_LEN+2);
    if (!string)
        return -1;

    ptrlist_init(&work);

    /* Determine number of sectors in constellation */
    nums = mtrandom_uint(GREEK_N);
    if (nums == 0)
        nums = 1;

    mprintf("addconstellation: will create %lu sectors (universe has %lu so far)\n", nums, ptrlist_len(&univ.sectors));

    pthread_rwlock_wrlock(&univ.sectornames_lock);

    fs = NULL;
    for (numc = 0; numc < nums; numc++) {

        /* Create a new sector and put it in s */
        s = malloc(sizeof(*s));
        if (!s)
            goto err;
        sprintf(string, "%s %s", greek[numc], cname);
        if (sector_create(s, string))
            goto err;

        ptrlist_push(&univ.sectors, s);
        st_add_string(&univ.sectornames, s->name, s);

        if (fs == NULL) {
            /* This was the first sector generated for this constellation
               We need to place this at a suitable point in the universe */
            fs = s;
            if (ptrlist_len(&univ.sectors) == 1) {
                /* The first constellation always goes in (0, 0) */
                if (sector_move(s, 0, 0))
                    bug("%s", "Error when placing first sector at (0,0)");
            } else {
                /* All others are randomly distributed */
                phi = mtrandom_uint(UINT_MAX) / (double)UINT_MAX*2*M_PI;
                r = 0;
                i = 2;
                while (i > 1) {
                    r += mtrandom_ulong(CONSTELLATION_RANDOM_DISTANCE);
                    phi += mtrandom_double(CONSTELLATION_PHI_RANDOM);
                    if (!sector_move(s, POLTOX(phi, r), POLTOY(phi, r)))
                        i = get_neighbouring_systems(NULL, s, CONSTELLATION_MIN_DISTANCE);
                }
            }
            ptrlist_push(&work, s);
        } else if (ptrlist_len(&work) == 0) {
            /* This isn't the first sector but no sectors are left in work
               Put this close to the first sector */
            ptrlist_push(&work, s);
            makeneighbours(fs, s, 0, 0);
        } else {
            /* We have sectors in work, put this close to work[0] and add this one to work */
            ptrlist_push(&work, s);
            makeneighbours(ptrlist_entry(&work, 0), s, 0, 0);
            /* Determine if work[0] has enough neighbours, if so remove it */
            if (mtrandom_uint(UINT_MAX) < UINT_MAX/CONSTELLATION_NEIGHBOUR_CHANCE)
                ptrlist_pull(&work);
        }

        mprintf("Created %s (%p) at %ldx%ld\n", s->name, s, s->x, s->y);

    }

    pthread_rwlock_unlock(&univ.sectornames_lock);

    free(string);
    ptrlist_free(&work);

    return 0;

err:
    pthread_rwlock_unlock(&univ.sectornames_lock);
    return -1;
}