示例#1
0
int main(int ____c, char *____v[])
{
	setup_error_handlers();
	gc_begin_func();
	STRING(s1);
	STRING(s2);
	STRING(t);
	bool s1t;
	bool s2t;
	s1 = String_new("hellp");
	s2 = String_new("aello");
	t = String_new("hello");
	s1t = str_gt(s1,t);
	if (s1t) {
		gt_msg(s1,t);
	}
	else {
		le_msg(s1,t);
	}
	s2t = str_gt(s2,t);
	if (s2t) {
		gt_msg(s2,t);
	}
	else {
		le_msg(s2,t);
	}
	gc_end_func();

	gc();
	Heap_Info info = get_heap_info();
	if ( info.live!=0 ) fprintf(stderr, "%d objects remain after collection\n", info.live);
	gc_shutdown();
	return 0;
}
示例#2
0
/* Initialize a heap with a certain size for use with the garbage collector */
void gc_init(int size) {
	if (heap != NULL ) { gc_shutdown(); }
    heap_size = (size_t)size;
    heap = morecore((size_t)size);
    end_of_heap = heap + size - 1;
    next_free = heap;
    num_roots = 0;
}
示例#3
0
void obj_shutdown(void)
{
    gc_shutdown();
    _obj_nil = 0;
    _obj_true = 0;
    _obj_false = 0;
    sym_clear();
}
示例#4
0
int main(int argc, char** argv)
{
  ga_Format fmt;
  ga_Device* dev;
  gc_int16* buf;
  gc_int32 numSamples;
  gc_int32 sampleSize;
  gc_int32 numToQueue;
  gc_int32 i;
  gc_int16 sample;
  gc_float32 pan = 1.0f;
  gc_float32 t = 0.0f;

  /* Initialize library + device */
  gc_initialize(0);
  memset(&fmt, 0, sizeof(ga_Format));
  fmt.bitsPerSample = 16;
  fmt.numChannels = 2;
  fmt.sampleRate = 44100;
  numSamples = 2048;
  sampleSize = ga_format_sampleSize(&fmt);
  dev = ga_device_open(GA_DEVICE_TYPE_DEFAULT, 2, 2048, &fmt);
  if(!dev)
    return 1;

  /* Allocate buffer */
  buf = (gc_int16*)malloc(numSamples * sampleSize);

  /* Infinite mix loop */
  while(1)
  {
    numToQueue = ga_device_check(dev);
    while(numToQueue--)
    {
      for(i = 0; i < numSamples * 2; i = i + 2)
      {
        sample = (gc_int16)(sin(t) * 32768);
        sample = (sample > -32768 ? (sample < 32767 ? sample : 32767) : -32768);
        pan = (gc_float32)sin(t / 300) / 2.0f + 0.5f;
        buf[i] = (gc_int16)(sample * pan);
        buf[i + 1] = (gc_int16)(sample * (1.0f - pan));
        t = t + 0.03f;
        if(t > 3.14159265f)
          t -= 3.14159265f;
      }
      ga_device_queue(dev, (char*)buf);
    }
  }

  /* Clean up device + library */
  ga_device_close(dev);
  gc_shutdown();

  /* Free buffer */
  free(buf);

  return 0;
}
示例#5
0
/* Initialize a heap with a certain size for use with the garbage collector */
void gc_init(int size) {
    if ( start_of_heap!=NULL ) { gc_shutdown(); }
    heap_size = (size_t)size;
    start_of_heap = morecore((size_t)size);
    end_of_heap = start_of_heap + size - 1;
    alloc_bump_ptr = start_of_heap;
    free_list = NULL;
    num_roots = 0;
}
示例#6
0
	void SoundManager::Clean()
	{
		for (uint i = 0; i < m_Sounds.size(); i++)
			delete m_Sounds[i];
#ifdef BARKLEY_PLATFORM_WEB
#else
		gau_manager_destroy(m_Manager);
		gc_shutdown();
#endif

	}
示例#7
0
	void SoundManager::clean()
	{
		for (int i = 0; i < m_Sounds.size(); i++)
			delete m_Sounds[i];

#ifdef SPARKY_EMSCRIPTEN
#else
		gau_manager_destroy(m_Manager);
		gc_shutdown();
#endif
	}
int main(int argc, char** argv){
    register void* base asm("ebp");
    gc_init(100, base, false);
    
    void* x1 = gc_malloc(49);
    void* x2 = gc_malloc(49);
    assert(x2 != NULL);
    x1 = gc_malloc(49);
    assert(x1 == NULL);
    gc_shutdown();

    return 0;
}
示例#9
0
int main(int ____c, char *____v[])
{
	setup_error_handlers();
	gc_begin_func();
	int argc;
	STRING(argv);
	argc = 1;
	argv = String_new("hello world");
	print_string(String_add(argv,String_from_int(argc)));
	gc_end_func();

	gc();
	Heap_Info info = get_heap_info();
	if ( info.live!=0 ) fprintf(stderr, "%d objects remain after collection\n", info.live);
	gc_shutdown();
	return 0;
}
示例#10
0
int main(int ____c, char *____v[])
{
	setup_error_handlers();
	gc_begin_func();
	int x;
	double y;
	x = 1;
	y = (3.14 + x);
	printf("%1.2f\n", y);
	gc_end_func();

	gc();
	Heap_Info info = get_heap_info();
	if ( info.live!=0 ) fprintf(stderr, "%d objects remain after collection\n", info.live);
	gc_shutdown();
	return 0;
}
示例#11
0
int main(int argc, char** argv)
{
  gau_Manager* mgr;
  ga_Mixer* mixer;
  ga_Sound* sound;
  ga_Handle* handle;
  gau_SampleSourceLoop* loopSrc = 0;
  gau_SampleSourceLoop** pLoopSrc = &loopSrc;
  gc_int32 loop = 0;
  gc_int32 quit = 0;

  /* Initialize library + manager */
  gc_initialize(0);
  mgr = gau_manager_create();
  mixer = gau_manager_mixer(mgr);

  /* Create and play shared sound */
  if(!loop)
    pLoopSrc = 0;
  sound = gau_load_sound_file("test.wav", "wav");
  handle = gau_create_handle_sound(mixer, sound, &setFlagAndDestroyOnFinish, &quit, pLoopSrc);
  ga_handle_play(handle);

  /* Bounded mix/queue/dispatch loop */
  while(!quit)
  {
    gau_manager_update(mgr);
    printf("%d / %d\n", ga_handle_tell(handle, GA_TELL_PARAM_CURRENT), ga_handle_tell(handle, GA_TELL_PARAM_TOTAL));
    gc_thread_sleep(1);
  }

  /* Clean up sound */
  ga_sound_release(sound);

  /* Clean up library + manager */
  gau_manager_destroy(mgr);
  gc_shutdown();

  return 0;
}
示例#12
0
int main(int argc, char** argv)
{
	//freeing and coalescing tests
    register void* base asm("ebp");
    bool initTest = gc_init(100, base, false);
    
	if(initTest == false)
	{
		printf("gc_init unsuccessful\n");
		return -1;
	}
	    
    void* test1 = gc_malloc(90);    
    void* test2 = gc_malloc(20);
	if(test2 != NULL)
	{
		printf("test2 malloc fail unsuccessful\n");
		return -1;
	}
    
    void* test3 = gc_malloc(10);
   
    gc_free(test1);	
	
	void* test4 = gc_malloc(20);
    void* test5 = gc_malloc(20);
	
	//uncomment this to test garbage collector and pointer in heap
	*((void**)test4) = test5;
	
   	test5 = gc_malloc(20);   
			
	print_heap();
	printf("**************\n");
	collect_garbage();
	print_heap();
	
	/* 
	Example Output:
	(with line 33 commented)
	Size: -1 In Use: true Address: 0x23a2010
	Size: 20 In Use: true Address: 0x23a2010
	Size: 20 In Use: true Address: 0x23a2024
	Size: 20 In Use: true Address: 0x23a2038
	Size: 30 In Use: false Address: 0x23a204c
	Size: 10 In Use: true Address: 0x23a206a
	**************
	Size: -1 In Use: true Address: 0x23a2010
	Size: 20 In Use: true Address: 0x23a2010
	Size: 20 In Use: false Address: 0x23a2024 //This becomes false after collection
	Size: 20 In Use: true Address: 0x23a2038
	Size: 30 In Use: false Address: 0x23a204c
	Size: 10 In Use: true Address: 0x23a206a
	End of Program.

	Example Output:
	(with line 33 NOT commented)
	
	*/
	
	
	gc_free(test5);			 
	gc_free(test3);
    gc_free(test4);

	
	gc_shutdown();
	
    printf("End of Program.\n");
    return 0;
}
示例#13
0
		AudioManager::~AudioManager() {
			gau_manager_destroy(m_Manager);
			gc_shutdown();
		}