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


C++ GC_free函数代码示例

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


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

示例1: GC_debug_free

GC_API void GC_CALL GC_debug_free(void * p)
{
    ptr_t base;
    if (0 == p) return;

    base = GC_base(p);
    if (base == 0) {
      GC_err_printf("Attempt to free invalid pointer %p\n", p);
      ABORT("Invalid pointer passed to free()");
    }
    if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
      GC_err_printf(
               "GC_debug_free called on pointer %p w/o debugging info\n", p);
    } else {
#     ifndef SHORT_DBG_HDRS
        ptr_t clobbered = GC_check_annotated_obj((oh *)base);
        word sz = GC_size(base);
        if (clobbered != 0) {
          GC_have_errors = TRUE;
          if (((oh *)base) -> oh_sz == sz) {
            GC_print_smashed_obj(
                  "GC_debug_free: found previously deallocated (?) object at",
                  p, clobbered);
            return; /* ignore double free */
          } else {
            GC_print_smashed_obj("GC_debug_free: found smashed location at",
                                 p, clobbered);
          }
        }
        /* Invalidate size (mark the object as deallocated) */
        ((oh *)base) -> oh_sz = sz;
#     endif /* SHORT_DBG_HDRS */
    }
    if (GC_find_leak
#       ifndef SHORT_DBG_HDRS
          && ((ptr_t)p - (ptr_t)base != sizeof(oh) || !GC_findleak_delay_free)
#       endif
        ) {
      GC_free(base);
    } else {
      hdr * hhdr = HDR(p);
      if (hhdr -> hb_obj_kind == UNCOLLECTABLE
#         ifdef ATOMIC_UNCOLLECTABLE
            || hhdr -> hb_obj_kind == AUNCOLLECTABLE
#         endif
          ) {
        GC_free(base);
      } else {
        size_t i;
        size_t obj_sz = BYTES_TO_WORDS(hhdr -> hb_sz - sizeof(oh));

        for (i = 0; i < obj_sz; ++i)
          ((word *)p)[i] = GC_FREED_MEM_MARKER;
        GC_ASSERT((word *)p + i == (word *)(base + hhdr -> hb_sz));
      }
    } /* !GC_find_leak */
}
开发者ID:dariaphoebe,项目名称:bdwgc,代码行数:57,代码来源:dbg_mlc.c

示例2: GC_debug_free

void GC_debug_free(void * p)
{
    ptr_t base;
    ptr_t clobbered;
    
    if (0 == p) return;
    base = GC_base(p);
    if (base == 0) {
        GC_err_printf("Attempt to free invalid pointer %p\n", p);
        ABORT("free(invalid pointer)");
    }
    if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {
        GC_err_printf(
        	  "GC_debug_free called on pointer %p wo debugging info\n", p);
    } else {
#     ifndef SHORT_DBG_HDRS
        clobbered = GC_check_annotated_obj((oh *)base);
        if (clobbered != 0) {
          if (((oh *)base) -> oh_sz == GC_size(base)) {
            GC_err_printf(
                  "GC_debug_free: found previously deallocated (?) object at ");
          } else {
            GC_err_printf("GC_debug_free: found smashed location at ");
          }
          GC_print_smashed_obj(p, clobbered);
        }
        /* Invalidate size */
        ((oh *)base) -> oh_sz = GC_size(base);
#     endif /* SHORT_DBG_HDRS */
    }
    if (GC_find_leak) {
        GC_free(base);
    } else {
	hdr * hhdr = HDR(p);
	GC_bool uncollectable = FALSE;

        if (hhdr ->  hb_obj_kind == UNCOLLECTABLE) {
	    uncollectable = TRUE;
	}
#	ifdef ATOMIC_UNCOLLECTABLE
	    if (hhdr ->  hb_obj_kind == AUNCOLLECTABLE) {
		    uncollectable = TRUE;
	    }
#	endif
	if (uncollectable) {
	    GC_free(base);
	} else {
	    size_t i;
	    size_t obj_sz = BYTES_TO_WORDS(hhdr -> hb_sz - sizeof(oh));

	    for (i = 0; i < obj_sz; ++i) ((word *)p)[i] = 0xdeadbeef;
	    GC_ASSERT((word *)p + i == (word *)(base + hhdr -> hb_sz));
	}
    } /* !GC_find_leak */
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:55,代码来源:dbg_mlc.c

示例3: destroy_list

void destroy_list(list_p list){
	lnode_p cur = list->first;
	lnode_p next;
	while(cur!=NULL){
		next = cur->next;
		list->destructor(cur->data);
		GC_free(cur);
		cur = next;
	}
	GC_free(list);
}
开发者ID:seven1m,项目名称:lidija,代码行数:11,代码来源:list.c

示例4: FNI_DestroyThreadState

void FNI_DestroyThreadState(void *cl) {
  struct FNI_Thread_State * env = (struct FNI_Thread_State *) cl;
  if (cl==NULL) return; // death of uninitialized thread.
  // ignore wrapped exception; free localrefs.
#ifdef WITH_REALTIME_JAVA
  RTJ_FREE(env->localrefs_stack);
#elif defined(WITH_PRECISE_GC)
  free(env->localrefs_stack);
#elif defined(BDW_CONSERVATIVE_GC)
  GC_free(env->localrefs_stack);
#else
  free(env->localrefs_stack);
#endif
  env->exception = /* this may point into localrefs_stack, so null it, too */
  env->localrefs_stack = env->localrefs_next = env->localrefs_end = NULL;
#if WITH_HEAVY_THREADS || WITH_PTH_THREADS
  // destroy condition variable & mutex
  pthread_mutex_unlock(&(env->sleep_mutex));
  pthread_mutex_destroy(&(env->sleep_mutex));
  pthread_cond_destroy(&(env->sleep_cond));
#endif
  // now free thread state structure.
#ifdef WITH_REALTIME_JAVA
  RTJ_FREE(env);
#elif WITH_TRANSACTIONS
  /* allocated with GC_malloc; no 'free' necessary. */
#else
  free(env);
#endif
}
开发者ID:fenghaitao,项目名称:Harpoon,代码行数:30,代码来源:jni-init.c

示例5: GC_win32_start_inner

void * GC_win32_start_inner(struct GC_stack_base *sb, LPVOID arg)
{
    void * ret;
    thread_args *args = (thread_args *)arg;

#   if DEBUG_WIN32_THREADS
      GC_printf("thread 0x%x starting...\n", GetCurrentThreadId());
#   endif

    GC_register_my_thread(sb); /* This waits for an in-progress GC. */

    /* Clear the thread entry even if we exit with an exception.	*/
    /* This is probably pointless, since an uncaught exception is	*/
    /* supposed to result in the process being killed.			*/
#ifndef __GNUC__
    __try {
#endif /* __GNUC__ */
	ret = (void *)(size_t)args->start (args->param);
#ifndef __GNUC__
    } __finally {
#endif /* __GNUC__ */
	GC_unregister_my_thread();
	GC_free(args);
#ifndef __GNUC__
    }
#endif /* __GNUC__ */

#   if DEBUG_WIN32_THREADS
      GC_printf("thread 0x%x returned from start routine.\n",
		GetCurrentThreadId());
#   endif
    return ret;
}
开发者ID:AntiTyping,项目名称:tinyrb,代码行数:33,代码来源:win32_threads.c

示例6: GC_free

void *talloc_atomic_uncollectable__(size_t size, const char *filename, int linenumber){
	void *ret;

	ret=tracker_alloc__(size,GC_malloc_atomic_uncollectable, filename, linenumber);

	if(ret!=NULL) return ret;

#if 0
	if(tmemoryisused==0){
		tmemoryisused=1;
		GC_free(tmemory);
		tmemory=NULL;
	}

#ifndef DISABLE_BDWGC
 	ret=GC_malloc_atomic_uncollectable(size);
#else
	ret=OS_getmem(size);		// For debugging. (wrong use of GC_malloced memory could be very difficult to trace)
#endif

#endif

        RWarning("Out of memory. I'll try to continue by allocating a different way, but you should save and quit now.\n");
        ret = calloc(1,size);
        
	if(ret!=NULL) return ret;


        RWarning("Didn't succeed. Out of memory. Quitting. (atomic_uncollectable allocator)\n");
	ShutDownYepp();
	return NULL;
}
开发者ID:onukore,项目名称:radium,代码行数:32,代码来源:memory.c

示例7: _init_thread_context

static void *_thread_internal2(void *arg){
    if(!arg) errquit("_thread_internal2: null arg");
    sinfo_t i = (sinfo_t) arg;
    _init_thread_context(i->tid,i->h);
//	 fprintf(stderr,"\n[%d]si = %p",tcb()->tid,i);
   // install top exception handler and execute thread if there's no exn
   if( _set_top_handler() == NULL ) {
#ifdef __RUNTIME_MEMORY_DEBUG_LOCKOP
            fprintf(stderr,"\n[%d] NEW THREAD.",	
              	 	tcb()->tid); 
#endif
	  (i->thread)((void *) (i+1));
   }
  // finalize thread context	 
//	fprintf(stderr,"\n[%d] fini_thread_context\n",i->tid);
  _fini_thread_context();
  // wake up main thread if I'm the last thread
  if(__sync_fetch_and_add(&all_done,-1) == 1)
   futex_wake((int *)&all_done,1);
  //HACK: generate segfault so as to switch
  //to the backup stack and free the current stack.
  // Mark the last page W/R. so that it can be deallocated
//  if (mprotect((void *) (((char *)i) + i->info.end_offset),1024,3))
//   errquit("__thread_internal2: mprotect failed.");

//  fprintf(stderr,"\n[%d]2 __si = %p",tcb()->tid,i);
  GC_free(i);
//  fprintf(stderr,"\n[%d]2 __si = %p. DONE",tcb()->tid,i);
  //goto_context(_thread_cleanup_stack,__second__stack,BACKUP_STK_SZ);
  //abort(); // should NOT reach this point
  pthread_exit(0); // should NOT reach this point
  return NULL;
}
开发者ID:pgerakios,项目名称:Concurrent-Cyclone-with-inference,代码行数:33,代码来源:runtime_stack.c

示例8: delete

void operator delete(void* p)
{
#ifdef DONT_COLLECT_STL
  GC_free(p); // Important to call this if you call GC_malloc_uncollectable
  // #else do nothing!
#endif
}
开发者ID:zecke,项目名称:boomerang,代码行数:7,代码来源:driver.cpp

示例9: sizeof

void *api_call_method(int numargs, void *obj, void *initptr, va_list vl)
{
    ffi_cif cif;
    ffi_type *args[numargs + 1];
    void *values[numargs + 1];
    void **val_heap = (void**)GC_malloc((numargs + 1) * sizeof(void*)); /*new void*[numargs + 1];*/
    void *rv;
    args[0] = &ffi_type_pointer;
    values[0] = &val_heap[0];
    for (int i = 0; i < numargs; i++)
    {
        args[i + 1] = &ffi_type_pointer;
        values[i + 1] = (void*)&val_heap[i + 1];
    }
    int rc = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, numargs + 1, &ffi_type_pointer, args);
    assert(rc == FFI_OK);
    val_heap[0] = (void*)obj;
    for (int i = 0; i < numargs; i++)
    {
        val_heap[i + 1] = va_arg(vl, void*);
    }
    ffi_call(&cif, (void(*)())initptr, &rv, values);
    va_end(vl);
    GC_free(val_heap);
    /*delete[] val_heap;*/
    return rv;
}
开发者ID:tmiw,项目名称:kite-llvm,代码行数:27,代码来源:api.cpp

示例10: GC_unregister_disappearing_link

int GC_unregister_disappearing_link(void * * link)
{
    struct disappearing_link *curr_dl, *prev_dl;
    size_t index;
    DCL_LOCK_STATE;
    
    LOCK();
    index = HASH2(link, log_dl_table_size);
    if (((word)link & (ALIGNMENT-1))) goto out;
    prev_dl = 0; curr_dl = dl_head[index];
    while (curr_dl != 0) {
        if (curr_dl -> dl_hidden_link == HIDE_POINTER(link)) {
            if (prev_dl == 0) {
                dl_head[index] = dl_next(curr_dl);
            } else {
                dl_set_next(prev_dl, dl_next(curr_dl));
            }
            GC_dl_entries--;
            UNLOCK();
#	    ifdef DBG_HDRS_ALL
	      dl_set_next(curr_dl, 0);
#	    else
              GC_free((void *)curr_dl);
#	    endif
            return(1);
        }
        prev_dl = curr_dl;
        curr_dl = dl_next(curr_dl);
    }
out:
    UNLOCK();
    return(0);
}
开发者ID:cansou,项目名称:minimallisp,代码行数:33,代码来源:finalize.c

示例11: GC_print_all_errors

/* Clear both lists.                                                    */
GC_INNER void GC_print_all_errors(void)
{
    static GC_bool printing_errors = FALSE;
    unsigned i;
    DCL_LOCK_STATE;

    LOCK();
    if (printing_errors) {
        UNLOCK();
        return;
    }
    printing_errors = TRUE;
    UNLOCK();
    if (GC_debugging_started) GC_print_all_smashed();
    for (i = 0; i < GC_n_leaked; ++i) {
        ptr_t p = GC_leaked[i];
        if (HDR(p) -> hb_obj_kind == PTRFREE) {
            GC_err_printf("Leaked atomic object at ");
        } else {
            GC_err_printf("Leaked composite object at ");
        }
        GC_print_heap_obj(p);
        GC_err_printf("\n");
        GC_free(p);
        GC_leaked[i] = 0;
    }
    GC_n_leaked = 0;
    printing_errors = FALSE;
}
开发者ID:bencz,项目名称:DotGnu,代码行数:30,代码来源:reclaim.c

示例12: pcc_pcre_free

void pcc_pcre_free(void *ptr)
{
   // the GC should free this for us, but
   // docs say we can free it ourselves and save
   // a collection for possibly faster performance
   GC_free(ptr);
}
开发者ID:96Levels,项目名称:roadsend-php,代码行数:7,代码来源:php-pcre.c

示例13: cuD_ufree_atomic

void
cuD_ufree_atomic(void *ptr, char const *file, int line)
{
#ifdef CUCONF_HAVE_GC_MALLOC_ATOMIC_UNCOLLECTABLE
    GC_free(ptr);
#else
    free(ptr);
#endif
}
开发者ID:paurkedal,项目名称:culibs,代码行数:9,代码来源:memory.c

示例14: list_poll

void* list_poll(list_p list){
	lnode_p first = list->first;
	if(first == NULL) return NULL;
	list->first = first->next;
	void* data = first->data;
	first->next->prev = NULL;
	GC_free(first);
	return data;
}
开发者ID:seven1m,项目名称:lidija,代码行数:9,代码来源:list.c

示例15: list_pop

void* list_pop(list_p list){
	lnode_p last = list->last;
	if(last == NULL) return NULL;
	list->last = last->prev;
	void* data = last->data;
	last->prev->next = NULL;
	GC_free(last);
	return data;
}
开发者ID:seven1m,项目名称:lidija,代码行数:9,代码来源:list.c


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