Esempio n. 1
0
GAULFUNC void ga_chromosome_integer_deallocate( population *pop,
                                       entity *corpse )
  {

  if (!pop) die("Null pointer to population structure passed.");
  if (!corpse) die("Null pointer to entity structure passed.");

  if (corpse->chromosome==NULL)
    die("This entity already contains no chromosomes.");

#ifdef USE_CHROMO_CHUNKS
  THREAD_LOCK(pop->chromo_chunk_lock);
  mem_chunk_free(pop->chromo_chunk, corpse->chromosome[0]);
  mem_chunk_free(pop->chromoarray_chunk, corpse->chromosome);
  corpse->chromosome=NULL;

  if (mem_chunk_isempty(pop->chromo_chunk))
    {
    mem_chunk_destroy(pop->chromo_chunk);
    mem_chunk_destroy(pop->chromoarray_chunk);
    pop->chromo_chunk = NULL;
    }
  THREAD_UNLOCK(pop->chromo_chunk_lock);
#else
  s_free(corpse->chromosome[0]);
  s_free(corpse->chromosome);
  corpse->chromosome=NULL;
#endif

  return;
  }
Esempio n. 2
0
static void 
hash_item_free(hashlist_t *hl, hash_item_t *item)
{
  RUNTIME_ASSERT(hl != NULL);
  RUNTIME_ASSERT(item != NULL);

  mem_chunk_free(item, sizeof *item);
}
Esempio n. 3
0
void
list_free(list_t *list)
{
  if (list) {
    node_t *n, *next;

    LIST_CHECK(list);

    for (n = list->first; n != NULL; n = next) {
      next = n->next;
      node_free(n);
    }

    mem_chunk_free(list, sizeof *list);
  }
}
Esempio n. 4
0
static void write_chunks_to_output_stream (GioDownload *download) 
{
	if (download->priv->chunks == NULL)
		return;
	
	GError *error = NULL;	
	download->priv->chunks = g_slist_reverse (download->priv->chunks); /* Important */
	MemChunk *chunk = flatten_mem_chunks (download->priv->chunks);
	
	g_output_stream_write  (G_OUTPUT_STREAM (download->priv->output), chunk->data, chunk->size, NULL, &error); 
	handle_critical_error (error);

	g_slist_free_full (download->priv->chunks, (GDestroyNotify)mem_chunk_free);
	download->priv->chunks = NULL;
	mem_chunk_free (chunk);
}
Esempio n. 5
0
void
http_destruct(http_t *ctx)
{
  DO_FREE(ctx->range_set);
  mem_chunk_free(ctx->host, ctx->host_size);
  ctx->host = NULL;

  /* Free the extra headers, if any */
  while (ctx->extra_headers) {
    snode_t *next;
  
    next = ctx->extra_headers->next;
    snode_free(ctx->extra_headers);
    ctx->extra_headers = next;
  }
}
Esempio n. 6
0
void
http_set_host(http_t *ctx, const char *host)
{
  if (ctx->host) {
    mem_chunk_free(ctx->host, ctx->host_size);
    ctx->host = NULL;
    ctx->host_size = 0;
  }
  if (host) {
    const char *endptr;
    size_t len;

    endptr = strchr(host, ':');
    if (!endptr) {
      endptr = strchr(host, '\0');
    }
    len = endptr - host;
    ctx->host_size = 1 + len;
    ctx->host = mem_chunk_copy(host, ctx->host_size);
    ctx->host[len] = '\0';
  }
}
Esempio n. 7
0
void
node_free(node_t *n)
{
  RUNTIME_ASSERT(n != NULL);
  mem_chunk_free(n, sizeof *n);
}