Пример #1
0
/*
 * For a number of alternating rounds, allocate and deallocate
 * memory randomly.  Writing a certain pattern into allocated memory and
 * check that the pattern is retained until the free.
 *
 * This function assumes that mem_alloc and mem_free are thread-safe.
 */
static void *
test_single(void *arg)
{
    uint8_t *ptrs[NPTRS];
    size_t sizes[NPTRS];
    memset(ptrs, 0, sizeof ptrs);
    /* 'arg' is an integer used to seed our random numbers. */
    unsigned long seed = (unsigned long) arg;

    /* Alternate between an allocation and a deallocation round. */
    bool alloc = true;
    int j;
    for (j = 0; j < ROUNDS; j++)
    {
        int i;
        for (i = 0; i < NPTRS; i++)
        {
            /* Skip this entry with 50% probability. */
            if (rand_r(&seed) % 100 < 50)
            {
                continue;
            }

            if (alloc)
            {
                /* if entry is free, set target size and attempt allocation. */
                if (ptrs[i] == NULL)
                {
                    sizes[i] = (rand_r(&seed) % (ALLOCSIZE/4) + 1) * 4;
                }
                allocate_and_set(&ptrs[i], sizes[i]);
            }
            else
            {
                if (ptrs[i] != NULL)
                {
                    /* free entry if in use. */
                    check_and_free(&ptrs[i], sizes[i]);
                }
            }
        }

        alloc = !alloc;
    }

    /* Free all remaining entries. */
    int i;
    for (i = 0; i < NPTRS; i++)
    {
        if (ptrs[i] != NULL)
        {
            check_and_free(ptrs + i, sizes[i]);
        }
    }

    return NULL;
}
Пример #2
0
/**
 * ldap config
 */
void
ldap_config_free( ldap_config_t *c ){
  check_and_free( c->uri );
  check_and_free( c->binddn );
  check_and_free( c->bindpw );
  /* TLS */
  check_and_free( c->ssl );
  check_and_free( c->tls_cacertfile );
  check_and_free( c->tls_cacertdir );
  check_and_free( c->tls_certfile );
  check_and_free( c->tls_certkey );
  check_and_free( c->tls_ciphersuite );
  check_and_free( c->tls_reqcert );
  la_free( c );
}
Пример #3
0
/**
 * profile
 */
void
profile_config_free ( profile_config_t *c ){
  if( !c )
    return;

	check_and_free( c->basedn );
  check_and_free( c->search_filter );
  /* Group */
  check_and_free( c->groupdn );
  check_and_free( c->group_search_filter );
  check_and_free( c->member_attribute );
  check_and_free( c->default_pf_rules );
  /* redirect gateway */
  check_and_free( c->redirect_gateway_prefix );
  check_and_free( c->redirect_gateway_flags );
#ifdef ENABLE_LDAPUSERCONF
  check_and_free( c->default_profiledn );
#endif
	la_free( c );
}