• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ free_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中free_array函数的典型用法代码示例。如果您正苦于以下问题:C++ free_array函数的具体用法?C++ free_array怎么用?C++ free_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了free_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: f_tokenize

/*! @decl array(array(string)|string) tokenize(string code)
 *!
 *!   Tokenize a string of Pike tokens.
 *!
 *! @returns
 *!   Returns an array with Pike-level tokens and the remainder (a
 *!   partial token), if any.
 */
static void f_tokenize( INT32 args )
{
  struct array *res;
  struct pike_string *left_s = NULL; /* Make gcc happy. */
  struct pike_string *data;
  int left;
  ONERROR tmp;

  get_all_args("tokenize", args, "%W", &data);

  if(!data->len)
  {
    pop_n_elems(args);
    push_empty_array();
    push_empty_string();
    f_aggregate(2);
    return;
  }

  res = allocate_array_no_init( 0, 128 );
  SET_ONERROR(tmp, do_free_arrayptr, &res);
  
  switch(data->size_shift)
  {
    case 0:
      left = tokenize0(&res, STR0(data), data->len);
      left_s = make_shared_binary_string0(STR0(data)+left, data->len-left);
      break;
    case 1:
      left = tokenize1(&res, STR1(data), data->len);
      left_s = make_shared_binary_string1(STR1(data)+left, data->len-left);
      break;
    case 2:
      left = tokenize2(&res,STR2(data), data->len);
      left_s = make_shared_binary_string2(STR2(data)+left, data->len-left);
      break;
#ifdef PIKE_DEBUG
    default:
      Pike_error("Unknown shift size %d.\n", data->size_shift);
#endif
  }

  UNSET_ONERROR(tmp);
  pop_n_elems(args);
  if (!res->size) {
    free_array(res);
    push_empty_array();
  }
  else
    push_array(res);
  push_string( left_s );
  f_aggregate( 2 );
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:61,代码来源:pike.c


示例2: main

int main(int argc, const char * argv[]) {
	char filename[MAX_LENGTH];
	node_t * nodes[MAX_NODES];
	FILE * file;
	int count;
	int i;

    //check that there is correct number of arguments
	if (argc != 2) {
		printf("graphexec requires 2 arguments.\n");
        return -1;
    }
    
    //open file and check that it was sucessful
	file = fopen(argv[1], "r");
	if (!file) {
		printf("The file specified does not exist or could not be opened.\n");
	}
    
    //if things check out, proceed to read and process file
    else {
		count = read_file(file, nodes, MAX_NODES);
        bool finished;
        
		while (!finished) {
			finished = true;
			determine_eligible(nodes, count);
            
            //iterate through and run nodes that are marked READY
			for (i = 0; i < count; i++) {
				if (nodes[i]->status != FINISHED) {
					finished = false;
					if (nodes[i]->status == READY) {
						printf("Node %i Status: Running", i);
						if(run_node(nodes[i]) == FINISHED &&
                            run_node(nodes[i]) != -1) {
                            printf(" >> Finished!\n");
                        } else
                            perror("Error running node");
					}
				}
			}
		}
        
		//cleanup
		free_array(nodes, count);
        if (fclose(file) == -1)
            perror("Failed to close file");
	}
    
	return 0;
}
开发者ID:DarylX,项目名称:4061,代码行数:52,代码来源:main.c


示例3: mread_set_bg_source

/*
 * Set the background source to be used for pseudocounts.
 * The background is resolved by the following rules:
 * - If source is:
 *   null or "--nrdb--"       use nrdb frequencies
 *   "--uniform--"            use uniform frequencies
 *   "motif-file"             use frequencies in motif file
 *   file name                read frequencies from bg file
 */
void mread_set_bg_source(MREAD_T *mread, const char *source) {
  // clean up old bg
  if (mread->other_bg != NULL) free_array(mread->other_bg);
  mread->other_bg = NULL;
  if (mread->other_bg_src != NULL) free(mread->other_bg_src);
  mread->other_bg_src = NULL;
  // copy the passed source
  if (source != NULL) {
    mread->other_bg_src = strdup(source);
  }
  // check if we've chosen a parser already
  if (mread->success) set_pseudo_bg(mread);
}
开发者ID:a1aks,项目名称:Haystack,代码行数:22,代码来源:motif-in.c


示例4: shrink

/*
 shrink(double** A, double t, int M) applies the shrink operator on A with thresholding parameter t. 
 
 The idea is to compute the SVD of A, A=U*S*V, then create the matrix B

     B = U * S2 * V, 

     where S2_{i,i} = S_{i,i} if ((S_{i,i}-)*t>0) and 
           S2_{i,i} = 0 otherwise.
   
    Then it returns B.

*/
double* shrink(double* A, double tau, int nrows, int ncols, char method){
	int i;
	int info = 0;
	char JOBU = 'A';
	char JOBVT = 'A';

	int LWORK = fmax(fmax(1,3*fmin(nrows,ncols)+fmax(nrows,ncols)),5*fmin(nrows,ncols));
	double* WORK = alloc_array(1, LWORK);
	double* U = alloc_array(nrows, nrows);
	double* VT = alloc_array(ncols, ncols);
	double* S = alloc_array(fmin(nrows,ncols), fmin(nrows, ncols));
	int min_dim = fmin(nrows,ncols);
	
	dgesvd_(&JOBU, &JOBVT, &nrows, &ncols, A, &nrows, S, U, &nrows, VT, &ncols, WORK, &LWORK, &info);
	
	if( method == 'S' ){
		for( i = 0; i < min_dim; i++){
				S[i] = fmax(0.0, S[i] - tau);
		}
	}
	else if( method == 'P' ){
		#pragma omp parallel for
		for(i=0; i < min_dim;i++){
				S[i] = fmax(0.0, S[i] - tau);
		}
	}
	double* C = alloc_array_z(nrows,ncols);
	
	//C = mm(mm(U, nrows, nrows, 't', diag(S,nrows, ncols), nrows, ncols, 'n'), nrows, ncols, 'n', VT, ncols, ncols, 't');
	C = mm(mm(VT, ncols, ncols, 'n', diag(S,ncols, nrows), ncols, nrows, 'n'), ncols, nrows, 'n', U, nrows, nrows, 'n');
	
	//free_array(A);
	free_array(WORK);
	free_array(U);
	free_array(VT);
	free_array(S);
	
	return C;
}	
开发者ID:kgourgou,项目名称:Matrix-Completion-in-C,代码行数:52,代码来源:shrink.c


示例5: mread_set_background

/*
 * Set the background to be used for pseudocounts.
 */
void mread_set_background(MREAD_T *mread, const ARRAY_T *bg) {
  // clean up old bg
  if (mread->other_bg != NULL) free_array(mread->other_bg);
  mread->other_bg = NULL;
  if (mread->other_bg_src != NULL) free(mread->other_bg_src);
  mread->other_bg_src = NULL;
  // copy the passed background
  if (bg != NULL) {
    mread->other_bg = allocate_array(get_array_length(bg));
    copy_array(bg, mread->other_bg);
  }
  // check if we've chosen a parser already
  if (mread->success) set_pseudo_bg(mread);
}
开发者ID:a1aks,项目名称:Haystack,代码行数:17,代码来源:motif-in.c


示例6: circuit_model

int circuit_model(graph_t * g, int nG)
{
    double **Gm;
    double **Gm_inv;
    int rv;
    long i, j;
    node_t *v;
    edge_t *e;

    Gm = new_array(nG, nG, 0.0);
    Gm_inv = new_array(nG, nG, 0.0);

    /* set non-diagonal entries */
    for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
	for (e = agfstedge(g, v); e; e = agnxtedge(g, e, v)) {
	    i = AGID(agtail(e));
	    j = AGID(aghead(e));
	    if (i == j)
		continue;
	    /* conductance is 1/resistance */
	    Gm[i][j] = Gm[j][i] = -1.0 / ED_dist(e);	/* negate */
	}
    }

    rv = solveCircuit(nG, Gm, Gm_inv);

    if (rv)
	for (i = 0; i < nG; i++) {
	    for (j = 0; j < nG; j++) {
		GD_dist(g)[i][j] =
		    Gm_inv[i][i] + Gm_inv[j][j] - 2.0 * Gm_inv[i][j];
	    }
	}
    free_array(Gm);
    free_array(Gm_inv);
    return rv;
}
开发者ID:DaniHaag,项目名称:jsPlumb_Liviz.js,代码行数:37,代码来源:circuit.c


示例7: getino

// Searches through the device along pathname for target file 
// Returns the target file's inode number if found
int getino(int device, const char* pathname)
{
    int ino = 0;
    char** name = NULL; 

    if(strcmp(pathname, "/") == 0)
        return ROOT_INODE;

    name = parse(pathname, "/");

    // Absolute or Relative?
    if(pathname[0] == '/')
        ino = search(root, name[0]);        // Absolute: start at root
    else
        ino = search(running->cwd, name[0]);// Relative: start at cwd

    if(ino <= 0)
    {
        free_array(name);
        return DOES_NOT_EXIST; 
    }

    // Continue search
    int i = 0;
    while(name[++i])
    {
        if((ino = search(iget(device, ino), name[i])) <= 0)
        {
            free_array(name);
            return DOES_NOT_EXIST;
        }
    }

    free_array(name);
    return ino;
}
开发者ID:jsjessen,项目名称:360_SystemsProgramming,代码行数:38,代码来源:search.c


示例8: free_array

/* CLEANUP */
static void free_array(Meta **array, int size) {
    int index;
    Meta *meta;
    for (index = 0; index < size; index++) {
        meta = array[index]; // recursive cleaning
        if (meta->children->list)
            free_array(meta->children->list,
                       meta->children->index);
        free(meta->measure);
        free(meta->children);
        free(meta);
    }
    // free the main object
    free(array);
}
开发者ID:alexsilva,项目名称:lua_profiler,代码行数:16,代码来源:profiler.c


示例9: obj_read_mtllib_read_tr

void	obj_read_mtllib_read_tr(t_obj *obj, char *line)
{
	char	**datas;

	if (!(datas = ft_strsplit(line, ' ')))
		ERROR("ft_strsplit failed");
	if (!datas[0] || !datas[1] || datas[2])
		ERROR("invalid mtl tr line");
	if (!parse_valid_number(datas[1]))
		ERROR("invalid mtl tr value");
	if (!obj->current_mtl)
		ERROR("no current mtl for tr");
	obj->current_mtl->mtl.tr = 1 - ft_atod(datas[1]);
	free_array(datas);
}
开发者ID:acazuc,项目名称:42_scop,代码行数:15,代码来源:obj_read_mtllib_read_tr.c


示例10: free_lex_ctxt

void
free_lex_ctxt (lex_ctxt * c)
{
  int i;

#if 0
  if (c->exit_flag && c->up_ctxt != NULL)
    ((lex_ctxt *) c->up_ctxt)->exit_flag = 1;
#endif
  deref_cell (c->ret_val);
  free_array (&c->ctx_vars);
  for (i = 0; i < FUNC_NAME_HASH; i++)
    {
      free_func_chain (c->functions[i]);
    }
  efree (&c);
}
开发者ID:manfredgithub,项目名称:Openvas-Source,代码行数:17,代码来源:nasl_lex_ctxt.c


示例11: main

int main(int argc, char *argv[]) {

	int *array = random_gen(ARRAY_SIZE);

	printf("\n# ----- Original Data ----- #\n\n");
	print_array(array, ARRAY_SIZE);

	insertion_int(array, ARRAY_SIZE);

	printf("\n# ----- Sorted Data ----- #\n\n");
	print_array(array, ARRAY_SIZE);
	printf("\n");
	free_array(array);

	return 0;

}
开发者ID:Ap0c,项目名称:sorting,代码行数:17,代码来源:main.c


示例12: cudd_size

/* Use CUDD to compute number of BDD nodes to represent set of functions */
size_t cudd_size(shadow_mgr mgr, set_ptr roots) {
    if (!mgr->do_cudd)
	return 0;
    size_t nele = roots->nelements;
    DdNode **croots = calloc_or_fail(nele, sizeof(DdNode *), "cudd_size");
    word_t wr;
    int i = 0;
    set_iterstart(roots);
    while (set_iternext(roots, &wr)) {
	ref_t r = (ref_t) wr;
	DdNode *n = get_ddnode(mgr, r);
	croots[i++] = n;
    }
    int cnt = Cudd_SharingSize(croots, nele);
    free_array(croots, nele, sizeof(DdNode *));
    return (size_t) cnt;
}
开发者ID:rebryant,项目名称:Cloud-BDD,代码行数:18,代码来源:shadow.c


示例13: free_anon_var

static void
free_anon_var(anon_nasl_var* v)
{
  if (v == NULL)
    return;
  switch(v->var_type)
    {
    case VAR2_STRING:
    case VAR2_DATA:
      efree(&v->v.v_str.s_val);
      break;
    case VAR2_ARRAY:
      free_array(&v->v.v_arr);
      break;
    }
  efree(&v);

}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:18,代码来源:nasl_var.c


示例14: f_fetch_class_member

void f_fetch_class_member() {
   int pos = sp->u.number;
   array_t *arr;

   pos = sp->u.number;
   pop_stack();

   if( sp->type != T_CLASS )
      error( "Argument to fetch_class_member() not a class.\n" );

   arr = sp->u.arr;

   if( pos < 0 || pos >= arr->size )
      error( "Class index out of bounds.\n" );

   assign_svalue_no_free( sp, &arr->item[pos] );
   free_array( arr );
}
开发者ID:Yuffster,项目名称:fluffOS,代码行数:18,代码来源:dwlib.c


示例15: preload_objects

/* New version used when not in -o mode. The epilog() in master.c is
 * supposed to return an array of files (castles in 2.4.5) to load. The array
 * returned by apply() will be freed at next call of apply(), which means that
 * the ref count has to be incremented to protect against deallocation.
 *
 * The master object is asked to do the actual loading.
 */
void preload_objects (int eflag)
{
    VOLATILE array_t *prefiles;
    svalue_t *ret;
    VOLATILE int ix;
    error_context_t econ;

    save_context(&econ);
    if (SETJMP(econ.context)) {
        restore_context(&econ);
        pop_context(&econ);
        return;
    }
    push_number(eflag);
    ret = apply_master_ob(APPLY_EPILOG, 1);
    pop_context(&econ);
    if ((ret == 0) || (ret == (svalue_t *)-1) || (ret->type != T_ARRAY))
        return;
    else
        prefiles = ret->u.arr;
    if ((prefiles == 0) || (prefiles->size < 1))
        return;

    debug_message("\nLoading preloaded files ...\n");
    prefiles->ref++;
    ix = 0;
    /* in case of an error, effectively do a 'continue' */
    save_context(&econ);
    if (SETJMP(econ.context)) {
        restore_context(&econ);
        ix++;
    }
    for ( ; ix < prefiles->size; ix++) {
        if (prefiles->item[ix].type != T_STRING)
            continue;

        set_eval(max_cost);

        push_svalue(((array_t *)prefiles)->item + ix);
        (void) apply_master_ob(APPLY_PRELOAD, 1);
    }
    free_array((array_t *)prefiles);
    pop_context(&econ);
}       /* preload_objects() */
开发者ID:Hobbitron,项目名称:tmi2_fluffos_v3,代码行数:51,代码来源:backend.c


示例16: gauss_elim

/************************************************
 * gauss_elim(matrix, pivots, size)             *
 * --                                           *
 *  Performs Gaussian Elimination on matrix     *
 *  sizeXsize, storing the pivot order in pivot *
 ************************************************/
void gauss_elim(double *m, int *pivot, int n) {
  int i, j, k, max, temp;
  double s, s_max, pivot_el, pivot_el_max;
  double *scale = (double *) malloc(sizeof(double)*n);

  //print_matrix(stdout, m, n, n);
  
  //find largest value in each row
  for (i = 0; i < n; ++i) {
    s = s_max = 0;
    for (j = 0; j < n; ++j) {
      if ((s = fabs(m[(i*n)+j])) > s_max) {
        s_max = s;
      }
    }
    scale[i] = s_max;
  }

  //get largest element from each column
  for (j = 0; j < n-1; ++j) {
    pivot_el_max = -10e37;
    for (i = j; i < n; ++i) {
      pivot_el = fabs(m[(pivot[i]*n)+j]) / scale[pivot[i]];
      if (pivot_el > pivot_el_max) {
        pivot_el_max = pivot_el;
        max = i;
      }
    }
    //Interchange Row op
    temp = pivot[j];
    pivot[j] = pivot[max];
    pivot[max] = temp;
    for (i = j+1; i < n; ++i) {
      m[(pivot[i]*n)+j] /= m[(pivot[j]*n)+j];

      //other elements are affected
      for (k = j+1; k < n; ++k) {
        m[(pivot[i]*n)+k] -= (m[(pivot[i]*n)+j] * m[(pivot[j]*n)+k]);
      }
    }
  }
  
  free_array((void *)scale);
}
开发者ID:kvjanos,项目名称:irodalom,代码行数:50,代码来源:shape_utils.c


示例17: free

SPHSystem::~SPHSystem()
{
	free(hMem);
	free(hParam);
	free(hPoints);

	free_array(dMem);
	free_array(dHash);
	free_array(dIndex);
	free_array(dStart);
	free_array(dEnd);
	free_array(dPoints);
}
开发者ID:NadineAB,项目名称:SPHfluid,代码行数:13,代码来源:sph_system.cpp


示例18: while

process *delete_process(process *head, pid_t pid){
	process *tmp = head;	
	if (head->pid == pid){
		head = head->next;
	}
	else {
		while (tmp->next != NULL){
			process *before = tmp;
			tmp = tmp->next;
			if (tmp->pid == pid){
				before->next = tmp->next;
				break;
			}
		}
	}
	free_array(tmp->command);
	free(tmp);
	return head;
}
开发者ID:duyatran,项目名称:cosc301-proj02,代码行数:19,代码来源:main.c


示例19: free_array

void g1_model_list_class::cleanup()
{
	free_array();
	if (g1_object_heap)
	{
		delete g1_object_heap;
	}

	if (name_buffer)
	{
		delete name_buffer;
	}

	if (array)
	{
		i4_free(array);
		array=0;
	}
}
开发者ID:pgrawehr,项目名称:golgotha,代码行数:19,代码来源:objs__model_id.cpp


示例20: bas_release_object

void bas_release_object(Object* object)
{
    object->ref_count --;
    if (object->ref_count == 0)
    {
        if (object->type == kTypeArray)
            free_array((Array*)object);
        else if (object->type == kTypeFunction)
            free_function((Function*)object);
        else if (object->type == kTypeString)
            free_string((String*)object);
        else
        {
            ASSERT(0); // object destructor not implemented!
        }
    }

    mem_free(object);
}
开发者ID:GrahamClemo,项目名称:bitbasic,代码行数:19,代码来源:basic.c



注:本文中的free_array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ free_basic_memory_bitmaps函数代码示例发布时间:2022-05-30
下一篇:
C++ free_and_strdup函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap