当前位置: 首页>>代码示例>>C++>>正文


C++ cl_free函数代码示例

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


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

示例1: DropVariable

int
DropVariable(Variable *vp)
{
  int i;

  Variable v = *vp;

  VariableDeleteItems(v);
  
  cl_free(v->my_name);
  cl_free(v->my_corpus); 
  cl_free(v->my_attribute);

  for (i = 0; i < nr_variables; i++)
    if (VariableSpace[i] == v) {
      VariableSpace[i] = NULL;
      break;
    }

  if (i >= nr_variables) {
    fprintf(stderr, "Error #5 in variable logic. Please contact developer.\n");
  }
  
  *vp = NULL;
  vp = NULL;
  
  return 1;
}
开发者ID:rforge,项目名称:rcwb,代码行数:28,代码来源:variables.c

示例2: malloc

  /* Parses world and inits possible positions. */
cop_knowledge_t *cl_init (FILE *file)
{
	cop_knowledge_t *c;
	node_line_t *startnode;

	c = malloc (sizeof (*c));
	if (!c) return NULL;

	bzero (c, sizeof (*c));

	c->world = parse_world_skeleton (file);
	
	c->map = build_map (c->world);
	if (!c->map) { 
		cl_free (c);
		return NULL;
	}

	c->prpsize = (c->map->num_nodes - 1) / (sizeof (int)*8) + 1;
	if (!new_turn (c)) {
		cl_free (c);
		return NULL;
	}

	startnode = node_by_loc (c->map, ROBBER_START_POS);
	if (!startnode) {
		dprintf ("ALERT: Start pos is not on map!!\n");
		exit (1);
	} 
	set_prp (c, startnode->index);
	c->prp_cnt[c->turn-1] = 1;
	
	return c; 
}
开发者ID:mbiely,项目名称:icfp-2005,代码行数:35,代码来源:coplib.c

示例3: comp_drop_component

/**
 * Delete a Component object.
 *
 * The specified component object, and all memory associated with it, is freed.
 *
 * @return Always 1.
 */
int
comp_drop_component(Component *comp)
{
  assert((comp != NULL) && "NULL component passed to attributes:comp_drop_component");

  assert(comp->attribute);

  if (comp->attribute->any.components[comp->id] != comp)
    assert(0 && "comp is not member of that attr");

  comp->attribute->any.components[comp->id] = NULL;

  if (comp->id == CompHuffCodes) {

    /* it may be empty, since declare_component doesn't yet load the
     * data */

    cl_free(comp->attribute->pos.hc);
  }

  mfree(&(comp->data));
  cl_free(comp->path);
  comp->corpus = NULL;
  comp->attribute = NULL;
  comp->id = CompLast;

  free(comp);

  return 1;
}
开发者ID:rforge,项目名称:rcwb,代码行数:37,代码来源:attributes.c

示例4: LogToCircularBuffer

void
LogToCircularBuffer(CircularBuffer_t *buffer, int level, const char *fmt, ...)
{
	va_list ap;
	char buf[MAXLINE];
	int	nbytes;
	CircularBufferEntry_t *entry = cl_malloc(sizeof(CircularBufferEntry_t));
	
	if (!entry) {
		return;
	}
	va_start(ap, fmt);
	nbytes=vsnprintf(buf, MAXLINE, fmt, ap);
	/*	nbytes=vasprintf(&buf, fmt, ap); */
	va_end(ap);

	entry->buf = buf;
	entry->level = level;

	g_queue_push_tail(buffer->queue, entry);

	while(buffer->queue->length > buffer->size) {
		entry = g_queue_pop_head(buffer->queue);
		cl_free(entry->buf);
		cl_free(entry);
	}
}
开发者ID:sipwise,项目名称:heartbeat,代码行数:27,代码来源:cl_log.c

示例5: cl_delete_kernel_bin

void cl_delete_kernel_bin(cl_kernel_bin_t *bins)
{
    if (bins)
    {
        cl_uint i = 0;
        if (bins->data)
        {
            for (i = 0; i < bins->numDevices; i++)
            {
                if (bins->data[i])
                {
                    cl_free(bins->data[i]);
                    bins->data[i] = NULL;
                }
            }
            cl_free(bins->data);
            bins->data = NULL;
        }
        if (bins->sizes)
        {
            cl_free(bins->sizes);
            bins->sizes = NULL;
        }
        // @TODO Fill in the structure with a bunch of garbage which will cause an abort later if dereferenced.
        //memset(bins, 0xFE, sizeof(cl_kernel_bin_t));
        cl_free(bins);
    }
}
开发者ID:richardxu,项目名称:panda-a4,代码行数:28,代码来源:clenvironment.c

示例6: cloudvpn_scheduler_run

int cloudvpn_scheduler_run (int* keep_running)
{
	struct work_queue*p;
	struct work*w;

	while (*keep_running) {

		cl_mutex_lock (queue_mutex);

		if (!queue) {
			/* just wait for the signal and retry */
			cl_cond_wait (queue_just_filled, queue_mutex);
			cl_mutex_unlock (queue_mutex);

		} else {

			p = queue;
			queue = queue->next;

			cl_mutex_unlock (queue_mutex);

			w = p->w;
			cl_free (p);

			do_work (w);

			/* don't delete statically assigned work */
			if (! (w->is_static) ) cl_free (w);
		}
	}

	return 0;
}
开发者ID:exaexa,项目名称:cloudvpn,代码行数:33,代码来源:sched.c

示例7: free_matchlist

/**
 * Frees all the memory used within a matchlist, and re-initialises all its variables */
void
free_matchlist(Matchlist *matchlist)
{
  cl_free(matchlist->start);
  cl_free(matchlist->end);
  cl_free(matchlist->target_positions);

  init_matchlist(matchlist);
}
开发者ID:rforge,项目名称:rcwb,代码行数:11,代码来源:matchlist.c

示例8: VerifyVariable

/** check variable's strings against corpus.attribute lexicon */
int
VerifyVariable(Variable v, 
               Corpus *corpus,
               Attribute *attribute)
{
  int i;

  int nr_valid, nr_invalid;

  if (v->valid == 0 || 
      v->my_corpus == NULL || v->my_attribute == NULL ||
      strcmp(v->my_corpus, corpus->registry_name) != 0 ||
      strcmp(v->my_attribute, attribute->any.name) != 0) {
    
    v->valid = 0;
    cl_free(v->my_corpus);
    cl_free(v->my_attribute);

    if (attribute->any.type != ATT_POS) {
      return 0;
    }

    v->my_corpus = cl_strdup(corpus->registry_name);
    v->my_attribute = cl_strdup(attribute->any.name);
    
    nr_valid = 0;
    nr_invalid = 0;
    
    for (i = 0; i < v->nr_items; i++) {

      if (!v->items[i].free) {
        if (v->items[i].sval == NULL) {
          fprintf(stderr, "Error #1 in variable logic. Contact developer.\n");
          v->items[i].ival = -1;
        }
        else
          v->items[i].ival = get_id_of_string(attribute, v->items[i].sval);

        if (v->items[i].ival < 0)
          nr_invalid++;
        else
          nr_valid++;
      }
    }
    
    v->nr_valid_items = nr_valid;
    v->nr_invalid_items = nr_invalid;
    
    if (nr_valid > 0)
      v->valid = 1;
    else
      v->valid = 0;
  }
  
  return v->valid;
}
开发者ID:rforge,项目名称:rcwb,代码行数:57,代码来源:variables.c

示例9: EmptyCircularBuffer

void
EmptyCircularBuffer(CircularBuffer_t *buffer) 
{
	CircularBufferEntry_t *entry = NULL;
	while(buffer->queue->length > 0) {
		entry = g_queue_pop_head(buffer->queue);
		cl_free(entry->buf);
		cl_free(entry);
	}
}
开发者ID:sipwise,项目名称:heartbeat,代码行数:10,代码来源:cl_log.c

示例10: LoadFontData

void LoadFontData()
{
	int		size;
	char	*lpMemory;
	size = readFile->ReadPackFile(pack_gparts,"mainFont.fnt",(char **)&lpMemory);
	CopyMemory(fontMain,lpMemory,size);
	cl_free(lpMemory);
	size = readFile->ReadPackFile(pack_gparts,"systemFont.fnt",(char **)&lpMemory);
	CopyMemory(fontSystem,lpMemory,size);
	cl_free(lpMemory);
} // LoadFontData
开发者ID:autch,项目名称:aquaplus_gpl,代码行数:11,代码来源:msgWnd.cpp

示例11: drop_single_mapping

/**
 * Deletes a SingleMapping object.
 *
 * @param smap  Address of the object to delete.
 * @return      Always 1.
 */
int
drop_single_mapping(SingleMapping *smap)
{

  cl_free((*smap)->class_name);
  cl_free((*smap)->tokens);

  free(*smap);
    
  *smap = NULL;
  return 1;
}
开发者ID:rforge,项目名称:rcwb,代码行数:18,代码来源:class-mapping.c

示例12: main

int main(int argc, char *argv[])
{
    const cl_uint numBodies = 10;
    float *m     = cl_malloc_array(float, numBodies);
    float *t     = cl_malloc_array(float, numBodies);
    cl_float4 *a = cl_malloc_array(cl_float4, numBodies);
    cl_float4 *v = cl_malloc_array(cl_float4, numBodies);
    cl_float4 *p = cl_malloc_array(cl_float4, numBodies);

#ifdef CL_BUILD_RUNTIME
    cl_uint type = clGetTypeFromString(CL_USER_DEVICE_TYPE);
    cl_uint count = CL_USER_DEVICE_COUNT;
    cl_environment_t *pEnv = clCreateEnvironment(KDIR"kernel_nbody.cl",type,count,notify,CL_ARGS);
#else
    cl_environment_t *pEnv = clCreateEnvironmentFromBins(&gKernelBins, notify, CL_ARGS);
#endif
    if (pEnv)
    {
        cl_uint i = 0, j = 0;
        cl_uint numIterations = (argc > 1?atoi(argv[1]):10);
        for (i = 0; i < numBodies; i++)
        {
            m[i] = frand() * ipow(10,rrand(4,27)); // masses should be 10^4 - 10^27 ("Earth heavy")
            frand4(a[i], 1, 3);
            frand4(v[i], 1, 2);
            frand4(p[i], 4, 8);
            t[i] = 0.001f; // 1 millisecond.
        }
        i = 0;
        for (j = 0; j < numIterations; j++)
        {
            nbodies(pEnv, m, a, v, p, t, numBodies);
#if defined(DARWIN)
            printf("[%6u] p={%lf,%lf,%lf} v={%lf,%lf,%lf} a={%lf,%lf,%lf}\n", i,
                    p[i][0], p[i][1], p[i][2],
                    v[i][0], v[i][1], v[i][2],
                    a[i][0], a[i][1], a[i][2]);
#else
            printf("[%6u] p={%lf,%lf,%lf} v={%lf,%lf,%lf} a={%lf,%lf,%lf}\n", i,
                    p[i].s[0], p[i].s[1], p[i].s[2],
                    v[i].s[0], v[i].s[1], v[i].s[2],
                    a[i].s[0], a[i].s[1], a[i].s[2]);
#endif     
        }
        clDeleteEnvironment(pEnv);
        cl_free(t);
        cl_free(m);
        cl_free(v);
        cl_free(a);
        cl_free(p);
    }
    return 0;
}
开发者ID:lavrovd,项目名称:OpenCL-Environment,代码行数:53,代码来源:nbody.c

示例13: DumpCircularBuffer

gboolean
DumpCircularBuffer(int nsig, gpointer user_data) 
{
	CircularBuffer_t *buffer = user_data;
	CircularBufferEntry_t *entry = NULL;
	
	if(buffer == NULL) {
		/* error */
		cl_log(LOG_ERR, "No buffer supplied to dump.");
		return FALSE;
	}

	if(logging_daemon_chan != NULL
	   && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
		/* We have no hope of getting the whole buffer out via the
		 *  logging daemon.  Use direct log instead so the messages
		 *  come out in the right order.
		 */ 
		cl_log_depth++;
	}
	
	cl_log(LOG_INFO, "Mark: Begin dump of buffer %s", buffer->name);
	if(buffer->empty_after_dump) {
		while(buffer->queue->length > 0) {
			entry = g_queue_pop_head(buffer->queue);
			cl_log(entry->level, "%s", entry->buf);
			cl_free(entry->buf);
			cl_free(entry);
		}

	} else {
#if 1
		cl_log(LOG_ERR, "This requires g_queue_peek_nth() from glib 2.4");
#else
		uint lpc = 0;
		uint queue_len = buffer->queue->length;
		for(lpc = 0; lpc < queue_len; lpc++) {
			entry = g_queue_peek_nth(buffer->queue, lpc);
			cl_log(entry->level, "%s", entry->buf);
		}
#endif
	}
	if(logging_daemon_chan != NULL
	   && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
		/* Return is back to normal */
		cl_log_depth--;
	}
	cl_log(LOG_INFO, "Mark: End dump of buffer %s", buffer->name);
	return TRUE;
}
开发者ID:sipwise,项目名称:heartbeat,代码行数:50,代码来源:cl_log.c

示例14: cloudvpn_scheduler_destroy

int cloudvpn_scheduler_destroy()
{
	struct work_queue*p;

	while (queue) {
		p = queue;
		queue = queue->next;
		cl_free (p->w);
		cl_free (p);
	}

	return cl_mutex_destroy (queue_mutex) ||
	       cl_cond_destroy (queue_just_filled);
}
开发者ID:exaexa,项目名称:cloudvpn,代码行数:14,代码来源:sched.c

示例15: free_tabulation_list

/** free global list of tabulation items (before building new one) */
void 
free_tabulation_list(void) {
  TabulationItem item = TabulationList;
  TabulationItem old = NULL;
  while (item) {
    cl_free(item->attribute_name);
    /* if we had proper reference counting, we would delete the attribute handle here
       (but calling cl_delete_attribute() would _completely_ remove the attribute from the corpus for this session!) */
    old = item;
    item = item->next;
    cl_free(old);
  }
  TabulationList = NULL;
}
开发者ID:rforge,项目名称:rcwb,代码行数:15,代码来源:output.c


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