コード例 #1
0
ファイル: RAutoPool.c プロジェクト: virpool/RayLanguage
void innerFree(pointer some) {
#ifdef R_POOL_DETAILED
    deallocator(((RPoolDescriptor*)some)->ptr);
#endif
    deallocator(some);

}
コード例 #2
0
region_type *region_create_custom(void *(*allocator)(size_t),
				  void (*deallocator)(void *),
				  size_t chunk_size,
				  size_t large_object_size,
				  size_t initial_cleanup_size,
				  int recycle)
{
	region_type* result = alloc_region_base(allocator, deallocator,
		initial_cleanup_size);
	if(!result)
		return NULL;
	assert(large_object_size <= chunk_size);
	result->chunk_size = chunk_size;
	result->large_object_size = large_object_size;
	if(result->chunk_size > 0) {
		result->data = (char *) allocator(result->chunk_size);
		if (!result->data) {
			deallocator(result->cleanups);
			deallocator(result);
			return NULL;
		}
		result->initial_data = result->data;
	}
	if(recycle) {
		result->recycle_bin = allocator(sizeof(struct recycle_elem*)
			* result->large_object_size);
		if(!result->recycle_bin) {
			region_destroy(result);
			return NULL;
		}
		memset(result->recycle_bin, 0, sizeof(struct recycle_elem*)
			* result->large_object_size);
	}
	return result;
}
コード例 #3
0
ファイル: xml.c プロジェクト: elambert/honeycomb
hcerr_t end_document_and_close (xml_writer *xml_writer, hc_long_t *length){
  hc_simple_xml_writer_t *writer = (hc_simple_xml_writer_t*) xml_writer;
  hc_tag_stack_t *stack = writer->tag_stack;

  assert(writer->document_tag != NULL);

  while (stack != NULL){
    require_ok(end_element(xml_writer, stack->tag));
    stack = writer->tag_stack;
  }
  require_ok(pretty_print(writer, FALSE));
  require_ok(hc_write(writer, "</"));
  require_ok(hc_write(writer, writer->document_tag));
  require_ok(hc_write(writer, ">"));
  if (PP_LF) {
    require_ok(hc_write(writer, "\n"));
  }

  *length = writer->position;

  if (writer->write_to_callback == TRUE){
    require_ok((writer->write_callback)(writer->buffer, writer->position, TRUE, writer->stream));
    assert(writer->buffer != NULL);
    deallocator(writer->buffer);
  }
  else {
    writer->buffer[writer->position] = 0;
  }

  deallocator(writer->document_tag);
  deallocator(writer);
  return HCERR_OK;
}
コード例 #4
0
ファイル: xml.c プロジェクト: elambert/honeycomb
static hcerr_t string_buffer_cleanup(buffer_cell_t *string_buffer){
  while (string_buffer != NULL){
    buffer_cell_t *trail = string_buffer;
    string_buffer = string_buffer->previous;
    
    if (trail->data) {
      deallocator(trail->data);
      trail->data = NULL;
    }
    deallocator(trail);
    trail = NULL;
  }
  
  return HCERR_OK;
}
コード例 #5
0
ファイル: RBuffer.c プロジェクト: tml/RayLanguage
RBuffer* makeRBufferOptions(size_t startSize, size_t objectCount) {
    RBuffer *object = allocator(RBuffer);
    if(object != nil) {
        // allocation of buffer
        master(object, RData) = makeRDataBytes(arrayAllocator(byte, startSize), startSize);
        if(master(object, RData) != nil) {

            // allocation of sizes array
            object->sizesArray = arrayAllocator(RRange, objectCount);

            if(object->sizesArray  != nil) {
                object->classId     = registerClassOnce(toString(RBuffer));
                object->freePlaces  = objectCount;
                object->count       = 0;
                object->totalPlaced = 0;
#ifdef RAY_BUFFER_THREAD_SAFE
                mutexWithType(&object->mutex, RMutexRecursive);
#endif
            } else {
                RError("RBuffer. Allocation of sizes array failed.", object);
                deleter(master(object, RData), RData);
            }
        } else {
            RError("RBuffer. Allocation of master RData failed.", object);
            deallocator(object);
            object = nil;
        }
    }
    return object;
}
コード例 #6
0
 Teuchos::ArrayRCP<typename ViewType::value_type>
 persistingView(
   const ViewType& view,
   typename Teuchos::ArrayRCP<typename ViewType::value_type>::size_type offset,
   typename Teuchos::ArrayRCP<typename ViewType::value_type>::size_type size) {
   return Teuchos::arcp(view.ptr_on_device()+offset, 0, size,
                        deallocator(view), false);
 }
コード例 #7
0
ファイル: multicell.c プロジェクト: elambert/honeycomb
hcerr_t free_multi_cell(silo_t *silo) {
    int i;

    assert(silo!=NULL);

    for (i = 0; i < MAX_CELLS; i++) {
      if (silo->cells[i] != NULL) {
        if (silo->cells[i]->addr != NULL) {
          deallocator(silo->cells[i]->addr);
        }
	deallocator(silo->cells[i]);
	silo->cells[i] = NULL;
      }
    }
    deallocator(silo);
    return HCERR_OK;
}
コード例 #8
0
region_type *
region_create(void *(*allocator)(size_t size),
	      void (*deallocator)(void *))
{
	region_type* result = alloc_region_base(allocator, deallocator,
		DEFAULT_INITIAL_CLEANUP_SIZE);
	if(!result)
		return NULL;
	result->data = (char *) allocator(result->chunk_size);
	if (!result->data) {
		deallocator(result->cleanups);
		deallocator(result);
		return NULL;
	}
	result->initial_data = result->data;

	return result;
}
コード例 #9
0
void		ftl_erase_pos(
	t_ftlist *l, t_ftlist_node *pos, void (*deallocator)())
{
	del(pos->prev, pos->next);
	if (deallocator != NULL)
		deallocator(pos);
	free(pos);
	l->size--;
	return ;
}
コード例 #10
0
ファイル: xml.c プロジェクト: elambert/honeycomb
static hcerr_t grow_attribute_arrays(simple_xml_parser *parser){
  char **names;
  char **values;
  int i = 0;

  //[???] Change the following to use "reallocator"
  ALLOCATOR(names, parser->attribute_arrays_size * 2 * sizeof(char*));
  ALLOCATOR(values, parser->attribute_arrays_size * 2 * sizeof(char*));

  for (i = 0; i < parser->current_attribute; i++){
    names[i] = parser->attribute_names[i];
    values[i] = parser->attribute_values[i];
  }
  parser->attribute_arrays_size = parser->attribute_arrays_size * 2;
  deallocator(parser->attribute_names);
  parser->attribute_names = names;
  deallocator(parser->attribute_values);
  parser->attribute_values = values;
  return HCERR_OK;
}
コード例 #11
0
ファイル: allocator.c プロジェクト: bbczeuz/opendnssec
/**
 * Cleanup allocator.
 *
 */
void
allocator_cleanup(allocator_type *allocator)
{
    void (*deallocator)(void *);
    if (!allocator) {
        return;
    }
    deallocator = allocator->deallocator;
    deallocator(allocator);
    return;
}
コード例 #12
0
void		ftl_pop_front(t_ftlist *l, void (*deallocator)())
{
	t_ftlist_node	*node;

	node = l->next;
	del(FTL_END(l), node->next);
	if (deallocator != NULL)
		deallocator(node);
	free(node);
	l->size--;
	return ;
}
コード例 #13
0
void		ftl_pop_back(t_ftlist *l, void (*deallocator)())
{
	t_ftlist_node	*node;

	node = l->prev;
	del(node->prev, FTL_END(l));
	if (deallocator != NULL)
		deallocator(node);
	free(node);
	l->size--;
	return ;
}
コード例 #14
0
ファイル: xml.c プロジェクト: elambert/honeycomb
hcerr_t xml_cleanup(xml_parser *formal_parser){
  simple_xml_parser *parser = (simple_xml_parser*) formal_parser;
  
  if (parser == NULL)
      return HCERR_OK;
  
  if (parser->buffer_list.string_buffer != NULL) {
    string_buffer_cleanup(parser->buffer_list.string_buffer);
    parser->buffer_list.string_buffer = NULL;
  }
  if (parser->attribute_names != NULL) {
    deallocator(parser->attribute_names);
    parser->attribute_names = NULL;
  }
  if (parser->attribute_values != NULL) {
    deallocator(parser->attribute_values);
      parser->attribute_values = NULL;
  }
  deallocator(parser);
  parser = NULL;
  formal_parser = NULL;
  return HCERR_OK;
}
コード例 #15
0
void
region_destroy(region_type *region)
{
	void (*deallocator)(void *);
	if (!region)
		return;

	deallocator = region->deallocator;

	region_free_all(region);
	deallocator(region->cleanups);
	deallocator(region->initial_data);
	if(region->recycle_bin)
		deallocator(region->recycle_bin);
	if(region->large_list) {
		struct large_elem* p = region->large_list, *np;
		while(p) {
			np = p->next;
			deallocator(p);
			p = np;
		}
	}
	deallocator(region);
}
コード例 #16
0
void		ftl_release(t_ftlist *l, void (*deallocator)())
{
	t_ftlist_node	*node;
	t_ftlist_node	*next;

	node = l->next;
	while (node != FTL_CEND(l))
	{
		next = node->next;
		del(node->prev, next);
		if (deallocator != NULL)
			deallocator(node);
		free(node);
		node = next;
	}
	*l = ftl_uninitialized();
	return ;
}
コード例 #17
0
void
region_free_all(region_type *region)
{
	size_t i;
	assert(region);
	assert(region->cleanups);

	i = region->cleanup_count;
	while (i > 0) {
		--i;
		assert(region->cleanups[i].action);
		region->cleanups[i].action(region->cleanups[i].data);
	}

	if(region->recycle_bin) {
		memset(region->recycle_bin, 0, sizeof(struct recycle_elem*)
			* region->large_object_size);
		region->recycle_size = 0;
	}

	if(region->large_list) {
		struct large_elem* p = region->large_list, *np;
		void (*deallocator)(void *) = region->deallocator;
		while(p) {
			np = p->next;
			deallocator(p);
			p = np;
		}
		region->large_list = NULL;
	}

	region->data = region->initial_data;
	region->cleanup_count = 0;
	region->allocated = 0;

	region->total_allocated = 0;
	region->small_objects = 0;
	region->large_objects = 0;
	region->chunk_count = 1;
	region->unused_space = 0;
}
コード例 #18
0
 Teuchos::ArrayRCP<typename ViewType::value_type>
 persistingView(const ViewType& view) {
   // mfh (05 Sep 2013) We use a custom deallocator that keeps the
   // view, but otherwise does nothing.  It doesn't deallocate the
   // view; it just maintains the reference count for the lifetime
   // of the deallocator object (and therefore, for the lifetime of
   // the ArrayRCP).  It seems weird that this is a nonowning
   // ArrayRCP (the last argument is false).  However, that's OK,
   // because (a) the ArrayRCP (actually, the underlying
   // RCPNodeTmpl; see Teuchos_RCPNode.hpp) keeps the deallocator
   // object regardless of whether the ArrayRCP is owning, and (b)
   // if we make this an owning ArrayRCP, the RCPNode tracking
   // system (in a debug build: Teuchos_ENABLE_DEBUG:BOOL=ON) will
   // report problems, because multiple owning ArrayRCPs have the
   // same raw pointer but not the same underlying RCPNode.  That
   // would be a problem if those ArrayRCPs shared memory that was
   // allocated (e.g.,) using new or malloc, but it's not a problem
   // here, because the custom deallocator does not free anything.
   // Nevertheless, it's better not to trouble the tracking system.
   return Teuchos::arcp(view.ptr_on_device(), 0, view.capacity(),
                        deallocator(view), false);
 }
コード例 #19
0
void WebResourceLoader::didReceiveResource(const ShareableResource::Handle& handle, double finishTime)
{
    LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResource for '%s'", m_coreLoader->url().string().utf8().data());

    RefPtr<ShareableResource> resource = ShareableResource::create(handle);
    if (!resource) {
        LOG_ERROR("Unabled to recreate the ShareableResource sent from the network process.");
        m_coreLoader->didFail(internalError(m_coreLoader->request().url()));
        return;
    }

    // Only send data to the didReceiveData callback if it exists.
    if (resource->size()) {
        RetainPtr<CFAllocatorRef> deallocator(AdoptCF, createShareableResourceDeallocator(resource));
        RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(resource->data()), static_cast<CFIndex>(resource->size()), deallocator.get()));

        RefPtr<SharedBuffer> buffer = SharedBuffer::wrapCFData(data.get());
        m_coreLoader->didReceiveBuffer(buffer.get(), buffer->size(), DataPayloadWholeResource);
    }

    m_coreLoader->didFinishLoading(finishTime);
}
コード例 #20
0
static region_type *
alloc_region_base(void *(*allocator)(size_t size),
		  void (*deallocator)(void *),
		  size_t initial_cleanup_count)
{
	region_type *result = (region_type *) allocator(sizeof(region_type));
	if (!result) return NULL;

	result->total_allocated = 0;
	result->small_objects = 0;
	result->large_objects = 0;
	result->chunk_count = 1;
	result->unused_space = 0;
	result->recycle_bin = NULL;
	result->recycle_size = 0;
	result->large_list = NULL;

	result->allocated = 0;
	result->data = NULL;
	result->initial_data = NULL;

	result->allocator = allocator;
	result->deallocator = deallocator;

	assert(initial_cleanup_count > 0);
	result->maximum_cleanup_count = initial_cleanup_count;
	result->cleanup_count = 0;
	result->cleanups = (cleanup_type *) allocator(
		result->maximum_cleanup_count * sizeof(cleanup_type));
	if (!result->cleanups) {
		deallocator(result);
		return NULL;
	}

	result->chunk_size = DEFAULT_CHUNK_SIZE;
	result->large_object_size = DEFAULT_LARGE_OBJECT_SIZE;
	return result;
}
コード例 #21
0
ファイル: xml.c プロジェクト: elambert/honeycomb
static void pop_tag (hc_tag_stack_t **top){
  hc_tag_stack_t *old_top = *top;
  *top = (*top)->enclosed_by;
  deallocator(old_top);
}
コード例 #22
0
GameObjectManager::~GameObjectManager() {
    std::for_each(m_container.begin(), m_container.end(), deallocator());
}
コード例 #23
0
ファイル: bufferObject.hpp プロジェクト: abadd/glTools
 void destroy()
 {
     deallocator(_vector.size(), _vector.data()); 
     _vector.clear();
 }