本文整理汇总了C++中cl_free函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_free函数的具体用法?C++ cl_free怎么用?C++ cl_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: drop_mapping
/**
* Deletes a Mapping object.
*
* @param map Address of the object to delete.
* @return Always 1.
*/
int
drop_mapping(Mapping *map)
{
(*map)->corpus = NULL;
(*map)->attribute = NULL;
cl_free((*map)->mapping_name);
cl_free((*map)->classes);
free(*map);
*map = NULL;
return 1;
}
开发者ID:rforge,项目名称:rcwb,代码行数:20,代码来源:class-mapping.c
示例17: sencode_parse_line
/**
* Parses an input line into cwb-s-encode.
*
* Usage:
*
* ok = sencode_parse_line(char *line, int *start, int *end, char **annot);
*
* Expects standard TAB-separated format; first two fields must be numbers,
* optional third field is returned in annot - if not present, annot is
* set to NULL.
*
* @param line The line to be parsed.
* @param start Location for the start cpos.
* @param end Location for the end cos.
* @param annot Location for the annotation string.
* @return Boolean; true for all OK, false for error.
*/
int
sencode_parse_line(char *line, int *start, int *end, char **annot)
{
char *field, *field_end;
char *line_copy = cl_strdup(line); /* work on copy to retain original for error messages */
int has_annotation = 1;
/* first field: INT range_start */
field = line_copy;
field_end = strchr(field, '\t');
if (field_end == NULL)
return 0;
else {
*field_end = 0;
errno = 0;
*start = atoi(field);
if (errno != 0 || *start < 0) return 0;
field = field_end + 1;
}
/* second field: INT range_end */
field_end = strchr(field, '\t');
if (field_end == NULL) {
has_annotation = 0;
field_end = strchr(field, '\n');
}
if (field_end == NULL)
return 0;
else {
*field_end = 0;
errno = 0;
*end = atoi(field);
if (errno != 0 || *end < 0) return 0;
field = field_end + 1;
}
/* optional third field: STRING annotation */
if (has_annotation) {
field_end = strchr(field, '\t');
if (field_end != NULL) {
return 0; /* make sure there are no extra fields */
}
else {
field_end = strchr(field, '\n');
if (field_end == NULL) {
return 0;
}
else {
*field_end = 0;
*annot = cl_strdup(field);
}
}
}
else {
*annot = NULL;
}
cl_free(line_copy);
return 1; /* OK */
}
开发者ID:rforge,项目名称:rcwb,代码行数:77,代码来源:cwb-s-encode.c
示例18: cl_log_args
void
cl_log_args(int argc, char **argv)
{
int lpc = 0;
int len = 0;
int existing_len = 0;
char *arg_string = NULL;
if(argc == 0 || argv == NULL) {
return;
}
for(;lpc < argc; lpc++) {
if(argv[lpc] == NULL) {
break;
}
len = 2 + strlen(argv[lpc]); /* +1 space, +1 EOS */
if(arg_string) {
existing_len = strlen(arg_string);
}
arg_string = cl_realloc(arg_string, len + existing_len);
sprintf(arg_string + existing_len, "%s ", argv[lpc]);
}
cl_log(LOG_INFO, "Invoked: %s", arg_string);
cl_free(arg_string);
}
开发者ID:sipwise,项目名称:heartbeat,代码行数:28,代码来源:cl_log.c
示例19: uncompress2compress
static int
uncompress2compress(struct ha_msg* msg, int index)
{
char* buf;
size_t buflen = MAXMSG;
int rc = HA_FAIL;
buf = cl_malloc(buflen);
if (!buf) {
cl_log(LOG_ERR, "%s: failed to allocate buffer",
__FUNCTION__);
goto err;
}
if (msg->types[index] != FT_UNCOMPRESS){
cl_log(LOG_ERR, "%s: the %dth field is not FT_UNCOMPRESS type",
__FUNCTION__, index);
goto err;
}
if (cl_compress_field(msg, index, buf, &buflen) != HA_OK){
cl_log(LOG_ERR, "%s: compressing %dth field failed", __FUNCTION__, index);
goto err;
}
rc = cl_msg_replace(msg, index, buf, buflen, FT_COMPRESS);
err:
if (buf) {
cl_free(buf);
}
return rc;
}
开发者ID:sipwise,项目名称:heartbeat,代码行数:35,代码来源:cl_msg_types.c
示例20: open_temporary_file
/**
* Creates, and opens for text-mode write, a temporary file.
*
* Temporary files have the prefix "$PID.cqpt." (where $PID = the process ID of this copy of CQP)
* and are placed in the directory defined as TEMPDIR_PATH.
*
* @see TEMPDIR_PATH
* @see TEMP_FILENAME_BUFSIZE
* @param tmp_nam_buffer A pre-allocated buffer which will be overwritten
* with the name of the temporary file. This should be at least
* TEMP_FILENAME_BUFSIZE bytes in size. If opening is unsuccessful,
* this will be set to "".
* @return A stream (FILE *) to the opened temporary file, or NULL
* if unsuccessful.
*/
FILE *
open_temporary_file(char *tmp_name_buffer)
{
char *intermed_buffer;
FILE *fd = NULL;
assert((tmp_name_buffer != NULL) && "Invalid NULL argument in open_temporary_file().");
/* note there is a potential problem using tempnam rather than tmpfile () or mkstemp () if there
* is more than one copy of cqp running and they both call this function at the same time.
* A race condition could result where copy#2 gets the same name as copy#1 by calling tempnam()
* after copy#1 calls it but before copy#1 opens the file.
*
* For this reason, the process ID is used to make the filename unique to this process.
* But we then need to try to open the file for read to check whether it exists (because
* tempnam() doesn't guarantee that the filename will still not exist once we add an
* arbitrary numerical prefix!)
*/
do {
if (fd)
fclose(fd);
intermed_buffer = tempnam(TEMPDIR_PATH, "cqpt."); /* we need to catch the pointer in order to free it below */
sprintf(tmp_name_buffer, "%d.%s", (int)getpid(), intermed_buffer);
cl_free(intermed_buffer);
} while (NULL != (fd = fopen(tmp_name_buffer, "r")));
fd = fopen(tmp_name_buffer, "w");
if (fd)
return fd;
else {
perror("open_temporary_file(): can't create temporary file");
return NULL;
}
}
开发者ID:rforge,项目名称:rcwb,代码行数:50,代码来源:output.c
注:本文中的cl_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论