// ----------------------------------------------------------------------------
void
vertex_buffer_clear( vertex_buffer_t *self )
{
    assert( self );

    vector_clear( self->indices );
    vector_clear( self->vertices );
    self->dirty = 1;
}
Exemple #2
0
// ----------------------------------------------------------------------------
void
vertex_buffer_clear( vertex_buffer_t *self )
{
    assert( self );

    self->state = FROZEN;
    vector_clear( self->indices );
    vector_clear( self->vertices );
    self->state = DIRTY;
}
Exemple #3
0
void
sip_calls_clear()
{
    // Create again the callid hash table
    htable_destroy(calls.callids);
    calls.callids = htable_create(calls.limit);
    // Remove all items from vector
    vector_clear(calls.list);
    vector_clear(calls.active);
}
Exemple #4
0
int main() 
{
    /* Create the vector */
    vector *v = vector_new(3);
    printf("Vector size: %d\n", vector_size(v));

    /* Add elements to the vector */
    vector_push(v, (void*)0);
    vector_push(v, (void*)11);
    vector_push(v, (void*)22);
    printf("Vector size: %d\n", vector_size(v));
    vector_push(v, (void*)33);
    vector_push(v, (void*)44);
    vector_push(v, (void*)55);
    vector_push(v, (void*)66);

    /* Get the size and print the elements */
    printf("Vector size: %d\n", vector_size(v));
    printf("Element 1: %d\n", vector_get(v, 0));
    printf("Element 2: %d\n", vector_get(v, 1));
    printf("Element 3: %d\n", vector_get(v, 2));
    printf("Element 4: %d\n", vector_get(v, 3));
    printf("Element 5: %d\n", vector_get(v, 4));
    printf("Element 6: %d\n", vector_get(v, 5));
    printf("Element 7: %d\n", vector_get(v, 6));

    /* Clear vector and print the size */
    vector_clear(v);
    printf("Vector size: %d\n", vector_size(v));

    /* We have not destructor at C, so clean up memory by ourselves */
    vector_free(v);

    return 0;
}
Exemple #5
0
bool matrix_normalize_constraint(pk_internal_t* pk,
                                 matrix_t* mat,
                                 size_t intdim, size_t realdim)
{
    bool change1, change2;
    size_t i;

    if ( pk->strict && realdim>0 ) {
        change2=false;
        for (i=0; i<mat->nbrows; i++) {
            change1 = vector_normalize_constraint(pk,mat->p[i],intdim,realdim);
            change2 = change2 || change1;
        }
        if (change2) {
            mat->_sorted = false;
            /* Add again \xi-\epsilon<=1 */
            size_t nbrows= mat->nbrows;
            matrix_resize_rows_lazy(mat,nbrows+1);
            vector_clear(mat->p[nbrows],mat->nbcolumns);
            numint_set_int(mat->p[nbrows][0],1);
            numint_set_int(mat->p[nbrows][polka_cst],1);
            numint_set_int(mat->p[nbrows][polka_eps],-1);
        }
        return change2;
    }
    else
        return false;
}
/* ------------------------------------------------------------------------- */
void
texture_atlas_clear( TextureAtlas *self )
{

    vector_clear( self->nodes );
    self->used = 0;
	{
    Node node = {0,0,self->width};
    vector_push_back( self->nodes, &node );

    memset( self->data, 0, self->width*self->height*self->depth );


	{
    // This is a special region that is used for background and underlined
    // decorations of glyphs
    int n = 4;
    //unsigned char buffer[n*n];
	unsigned char buffer[16];
    memset(buffer, 255, n*n);
	{
    Region r = texture_atlas_get_region( self, n, n );
    texture_atlas_set_region( self, r.x, r.y, r.width, r.height, buffer, 1);
    self->black.x     = r.x + 1;
    self->black.y     = r.y + 1;
    self->black.width = r.width - 2;
    self->black.height= r.height - 2;
	}
	}
	}
}
Exemple #7
0
/*
 * Free a vector completely.
 */
void
vector_free(struct vector *vector)
{
    vector_clear(vector);
    free(vector->strings);
    free(vector);
}
Exemple #8
0
void vector_destroy(vector **v)
{
    vector_clear(*v);
    free((*v)->items);
    free(*v);
    *v = NULL;
}
void
buf_dump(Buf *buffer, Vector<ch8> *string)
{
    vector_clear(string);

    ch8 *i = buf_page_begin(buffer);

    for (; i < buffer->gap_start; ++i) {
        vector_push(string, *i);
    }

    if (buffer->gap_start == buffer->gap_end) {
        vector_push(string, (ch8)'|');
    } else {
        for (; i < buffer->gap_end; ++i) {
            vector_push(string, (ch8)'#');
        }
    }


    for (; i < buf_data_end(buffer); ++i) {
        vector_push(string, *i);
    }

    for (; i < buf_page_end(buffer); ++i) {
        vector_push(string, (ch8)'-');
    }

#ifdef HALE_DEBUG
    hale_assert(vector_count(string) == buf_capacity);
#endif

    vector_push(string, (ch8)'\n');
}
Exemple #10
0
Fichier : test.c Projet : nexa/se
void vector()
{
  vector_t vec, *v;
  v = &vec;

  vector_init(v, 10);
  vector_fit(v, (void*)1);
  vector_fit(v, (void*)2);
  vector_fit(v, (void*)3);
  vector_fit(v, (void*)4);

 

  pvi(v);
  pvii(v, 2);

  vector_enable(v, 2);

  pvi(v);
  pvii(v, 2);
  vector_fit(v, (void*)5);
  pvi(v);
  pvii(v, 2);

  vector_clear(v);
}
Exemple #11
0
void runpath_list_clear( runpath_list_type * list ) {
  pthread_rwlock_wrlock( &list->lock );
  {
    vector_clear( list->list );
  }
  pthread_rwlock_unlock( &list->lock );
}
Exemple #12
0
void test4(void)
{
    vector_t vec = vector_from_string_list(NULL_VECTOR, "1920x1080,1280x720,720x576,720x480,704x576", NULL);
    vector_foreach(vec, test4_walker, NULL);
    printf("size: %d, capacity: %d\n", vector_size(vec), vector_capacity(vec));
    vector_clear(vec);
    vector_destroy(vec);
}
Exemple #13
0
void
query_result_destroy (query_result *r)
{
  if (!r)
    return;

  vector_clear(&(r->items));
  free(r);
}
Exemple #14
0
void matrix_fill_constraint_top(pk_internal_t* pk, matrix_t* C, size_t start)
{
  if (pk->strict){
    /* constraints epsilon and xi-epsilon*/
    vector_clear(C->p[start+0],C->nbcolumns);
    vector_clear(C->p[start+1],C->nbcolumns);
    numint_set_int(C->p[start+0][0],1);
    numint_set_int(C->p[start+0][polka_eps],1);
    numint_set_int(C->p[start+1][0],1);
    numint_set_int(C->p[start+1][polka_cst],1);
    numint_set_int(C->p[start+1][polka_eps],(-1));
  }
  else {
    /* constraint \xi \geq 0 */
    vector_clear(C->p[start+0],C->nbcolumns);
    numint_set_int(C->p[start+0][0],1);
    numint_set_int(C->p[start+0][polka_cst],1);
  }
}
Exemple #15
0
/*
 * Given a vector that we may be reusing, clear it out.  If the first argument
 * is NULL, allocate a new vector.  Used by vector_split*.
 */
static struct vector *
vector_reuse(struct vector *vector)
{
    if (vector == NULL)
        return vector_new();
    else {
        vector_clear(vector);
        return vector;
    }
}
Exemple #16
0
int
d_heal(struct command *c)
{
  int target = c->a;
  int aura = c->b;
  int chance;

  if (kind(target) != T_char) {
    wout(c->who, "%s is no longer a character.", box_code(target));
    return FALSE;
  }

  if (!char_sick(target)) {
    wout(c->who, "%s is not sick.", box_name(target));
    return FALSE;
  }

  if (!charge_aura(c->who, aura))
    return FALSE;

  switch (aura) {
  case 1:
    chance = 30;
    break;

  case 2:
    chance = 15;
    break;

  case 3:
    chance = 5;
    break;

  default:
    assert(FALSE);
  }

  vector_clear();
  vector_add(c->who);
  vector_add(target);

  wout(VECT, "%s casts Heal on %s:", box_name(c->who), box_name(target));

  if (rnd(1, 100) <= chance) {
    wout(VECT, "Spell fails.");
    return FALSE;
  }

  p_char(target)->sick = FALSE;

  wout(VECT, "%s has been cured, and should now recover.", box_name(target));

  return TRUE;
}
Exemple #17
0
Fichier : url.c Projet : mlmhl/cWeb
int set_value(values *v, const char *key, const char *val) {
	vector *values_set;
	if (hash_get(v, key, (void**)(&values_set)) == 0) {
		vector_clear(values_set);
	}
	else {
		vector_init(values_set, 1);
	}

	return v_push_ptr(values_set, (void*)val);
}
Exemple #18
0
void Animate::Destroy()
{
	unsigned int ani_frame_cnt = anim_frame_list.size();
	for (unsigned int i = 0; i < ani_frame_cnt; ++i)
		anim_frame_list.at(i)->retain();

	vector_clear(anim_frame_list);

	ObjectController::Instance()->removeChild(draw_spr, true);
	grap_effect.Destroy();
}
Exemple #19
0
static void vector_reset_value(void* _self, void* _value) {
  VectorSchema* self = _self;
  Vector* v = _value;
  if (v->_data) {
    for (unsigned i = 0; i < v->size; i++) {
      call(self->of, close_value, vector_get(v, i));
    }
    vector_clear(v);
  } else {
    vector_init(v, call(self->of, data_size), 4);
  }
}
Exemple #20
0
void
vector_destroy(vector_t *vector)
{
    // Nothing to free. Done.
    if (!vector) return;
    // Remove all items if a destroyer is set
    vector_clear(vector);
    // Deallocate vector list
    sng_free(vector->list);
    // Deallocate vector itself
    sng_free(vector);
}
Exemple #21
0
void test2(void)
{
    vector_t vec = vector_create2(0, 256);
    vector_set_option(vec, VECTOR_ELEMENT_COPY, (void*)strncpy);
    for (int i = 0; i < 10000; i++)
        vector_push_back(vec, "Hello, vector");
    vector_foreach(vec, test2_walker, NULL);
    printf("size: %d, capacity: %d\n", vector_size(vec), vector_capacity(vec));
    vector_add_flags(vec, VECTOR_FLAG_FASTCLEAR);
    vector_clear(vec);
    vector_destroy(vec);
}
Exemple #22
0
void test3(void)
{
    char buffer[8192];
    vector_t vec = vector_create_on_buffer(20, buffer, sizeof(buffer));
    vector_set_option(vec, VECTOR_ELEMENT_COPY, (void*)strncpy);
    for (int i = 0; i < 10000; i++)
        vector_push_back(vec, "Hello, vector on buffer");
    vector_foreach(vec, test2_walker, NULL);
    printf("size: %d, capacity: %d\n", vector_size(vec), vector_capacity(vec));
    vector_add_flags(vec, VECTOR_FLAG_FASTCLEAR);
    vector_clear(vec);
    vector_destroy(vec);
}
Exemple #23
0
/**
   This funcion is a feeble attempt at allowing the ensemble size to
   change runtime. If the new ensemble size is larger than the current
   ensemble size ALL the currently internalized misfit information is
   dropped on the floor; if the the ensemble is shrinked only the the
   last elements of the misfit table are discarded (NOT exactly battle-tested).

*/
void misfit_ensemble_set_ens_size( misfit_ensemble_type * misfit_ensemble , int ens_size) {
  int iens;
  if (ens_size > vector_get_size( misfit_ensemble->ensemble )) {
    /* The new ensemble is larger than what we have currently internalized, 
       we drop everything and add empty misfit_member instances. */
    vector_clear( misfit_ensemble->ensemble );
    for (iens = 0; iens < ens_size; iens++)
      vector_append_owned_ref( misfit_ensemble->ensemble , misfit_member_alloc( iens ) , misfit_member_free__);
    
  } else 
    /* We shrink the vector by removing the last elements. */
    vector_shrink( misfit_ensemble->ensemble , ens_size);
}
// ---------------------------------------------------- texture_atlas_clear ---
void
texture_atlas_clear( texture_atlas_t * self )
{
	assert( self );
	assert( self->data );

	vector_clear( self->nodes );
	self->used = 0;
	ivec3 node = {{0,0,self->width}};
	vector_push_back( self->nodes, &node );
	memset( self->data, 0, self->width*self->height*self->depth );
	self->dirty = true;
}
Exemple #25
0
// ------------------------------------------ texture_font_generate_kerning ---
void
texture_font_generate_kerning( texture_font_t *self )
{
    size_t i, j;
    FT_Library library;
    FT_Face face;
    FT_UInt glyph_index, prev_index;
    texture_glyph_t *glyph, *prev_glyph;
    FT_Vector kerning;
    
    assert( self );

    /* Load font */
//    if( !texture_font_load_face( &library, self->filename, self->size, &face ) )
//    {
//        return;
//    }
    if( !texture_font_load_face( self, &library, self->size, &face ) )// <----- changed
    {
        return;
    }

    /* For each glyph couple combination, check if kerning is necessary */
    /* Starts at index 1 since 0 is for the special backgroudn glyph */
    for( i=1; i<self->glyphs->size; ++i )
    {
        glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
        glyph_index = FT_Get_Char_Index( face, glyph->charcode );
        vector_clear( glyph->kerning );

        for( j=1; j<self->glyphs->size; ++j )
        {
            prev_glyph = *(texture_glyph_t **) vector_get( self->glyphs, j );
            prev_index = FT_Get_Char_Index( face, prev_glyph->charcode );
            FT_Get_Kerning( face, prev_index, glyph_index, FT_KERNING_UNFITTED, &kerning );
            // printf("%c(%d)-%c(%d): %ld\n",
            //       prev_glyph->charcode, prev_glyph->charcode,
            //       glyph_index, glyph_index, kerning.x);
            if( kerning.x )
            {
                // 64 * 64 because of 26.6 encoding AND the transform matrix used
                // in texture_font_load_face (hres = 64)
                kerning_t k = {prev_glyph->charcode, kerning.x / (float)(64.0f*64.0f)};
                vector_push_back( glyph->kerning, &k );
            }
        }
    }
    FT_Done_Face( face );
    FT_Done_FreeType( library );
}
// ---------------------------------------------------- texture_atlas_clear ---
void
texture_atlas_clear( texture_atlas_t * self )
{
    assert( self );
    assert( self->data );

    vector_clear( self->nodes );
    self->used = 0;
    // We want a one pixel border around the whole atlas to avoid any artefact when
    // sampling texture
    ivec3 node = {{1,1,self->width-2}};
    vector_push_back( self->nodes, &node );
    memset( self->data, 0, self->width*self->height*self->depth );
}
Exemple #27
0
bool workflow_run(workflow_type * workflow, void * self , bool verbose , const subst_list_type * context) {
  vector_clear( workflow->stack );
  workflow_try_compile( workflow , context);

  if (workflow->compiled) {
    int icmd;
    for (icmd = 0; icmd < vector_get_size( workflow->cmd_list ); icmd++) {
      const cmd_type * cmd = vector_iget_const( workflow->cmd_list , icmd );
      void * return_value = workflow_job_run( cmd->workflow_job, self , verbose , cmd->arglist );
      vector_push_front_ref( workflow->stack , return_value );
    }
    return true;
  } else
    return false;
}
Exemple #28
0
// ----------------------------------------------------------------------------
void
text_buffer_clear( text_buffer_t * self )
{
    assert( self );

    vertex_buffer_clear( self->buffer );
    self->line_start = 0;
    self->line_ascender = 0;
    self->line_descender = 0;
    vector_clear( self->lines );
    self->bounds.left   = 0.0;
    self->bounds.top    = 0.0;
    self->bounds.width  = 0.0;
    self->bounds.height = 0.0;
}
Exemple #29
0
void dir_destroy_all(void) {
    vector_clear(active_dirs);
    List *dir = root_dir.list.next;
    while(dir != NULL) {
	List* t = dir->next;
	// FIXME: use container
	dir_destroy((Dir*)dir);
	dir = t;
    }
    //fprintf(stderr, "Destroying dir %s\n", root_path);
    int res = rmdir(root_path);
    if (res != 0 && errno != ENOENT) {
	perror(root_path);
    }    
}
void test__rb_tree_iterator_get_value__libcstl_builtin(void** state)
{
    _rb_tree_t* pt_rb_tree = _create_rb_tree("vector_t<int>");
    _rb_tree_iterator_t it_iter;
    vector_t* pvec = create_vector(int);
    _rb_tree_init(pt_rb_tree, NULL);
    vector_init_n(pvec, 10);
    _rb_tree_insert_unique(pt_rb_tree, pvec);

    it_iter = _rb_tree_begin(pt_rb_tree);
    vector_clear(pvec);
    _rb_tree_iterator_get_value(it_iter, pvec);
    assert_true(vector_size(pvec) == 10);

    _rb_tree_destroy(pt_rb_tree);
}