Ejemplo n.º 1
0
Archivo: util.cpp Proyecto: 8l/zl
void pos_to_str(Pos p, OStream & buf) {
  if (p.name.empty())
    buf.write("<anon>");
  else
    buf.write(p.name);
  if (p.line == NPOS)
    ;//buf.write(":");
  else if (p.col == NPOS)
    buf.printf(":%u", p.line);
  else
    buf.printf(":%u:%u", p.line, p.col);
}
Ejemplo n.º 2
0
/* Released all unfree'd memory from all pools */
void mem_release_all()
{
#if defined(MEM_RECLAIM)
  OStream *f = NULL;
  MEMNODE *p, *tmp;
  size_t totsize;

  Send_Progress("Reclaiming memory", PROGRESS_RECLAIMING_MEMORY);

  p = memlist;
  totsize = 0;

#if defined(MEM_TRACE)
  if (p != NULL)
    f = New_OStream(MEM_LOG_FNAME, POV_File_Data_LOG, true);
#endif

  while (p != NULL)
  {
#if defined(MEM_TRACE)

    #if defined(MEM_TAG)
    if (!mem_check_tag(p))
      Debug_Info("mem_release_all(): Memory pointer corrupt!\n");
    #endif /* MEM_TAG */

    totsize += (p->size - NODESIZE - (MEM_GUARD_SIZE * 2));
    if (!leak_msg)
    {
      Debug_Info("Memory leakage detected, see file '%s' for list\n",MEM_LOG_FNAME);
      leak_msg = true;
    }

    if (f != NULL)
      f->printf("File:%13s  Line:%4d  Size:%lu\n", p->file, p->line, (unsigned long)(p->size - NODESIZE - (MEM_GUARD_SIZE * 2)));
#endif

#if defined(MEM_STATS)
    /* This is after we have printed stats, and this may slow us down a little,      */
    /* so we may want to simply re-initialize the mem-stats at the end of this loop. */
    mem_stats_free(p->size);
#endif

    tmp = p;
    p = p->next;
    remove_node(tmp);
    FREE(tmp);
  }

  if (f != NULL)
    delete f;

  if (totsize > 0)
    Debug_Info("\n%lu bytes reclaimed\n", totsize);

  poolno = 0;
  memlist = NULL;
#endif

#if defined(MEM_STATS)
  /* reinitialize the stats structure for next time through */
  mem_stats_init();
#endif

}
Ejemplo n.º 3
0
/* Releases all unfree'd memory from current memory pool */
void mem_release()
{
#if defined(MEM_RECLAIM)
  OStream *f = NULL;
  MEMNODE *p, *tmp;
  size_t totsize;

  p = memlist;
  totsize = 0;

#if defined(MEM_TRACE)
  if (p != NULL && (p->poolno == poolno))
    f = New_OStream(MEM_LOG_FNAME, POV_File_Data_LOG, true);
#endif /* MEM_TRACE */

  while (p != NULL && (p->poolno == poolno))
  {
#if defined(MEM_TRACE)

#if defined(MEM_TAG)
    if (!mem_check_tag(p))
      Debug_Info("mem_release(): Memory pointer corrupt!\n");
#endif /* MEM_TAG */

    totsize += (p->size - NODESIZE - (MEM_GUARD_SIZE * 2));
    if (!leak_msg)
    {
      Debug_Info("Memory leakage detected, see file '%s' for list\n",MEM_LOG_FNAME);
      leak_msg = true;
    }

    if (f != NULL)
      f->printf("File:%13s  Line:%4d  Size:%lu\n", p->file, p->line, (unsigned long)(p->size - NODESIZE - (MEM_GUARD_SIZE * 2)));
#endif /* MEM_TRACE */

#if defined(MEM_STATS)
    mem_stats_free(p->size);
#endif

    tmp = p;
    p = p->next;
    remove_node(tmp);
    FREE(tmp);
  }

  if (f != NULL)
    delete f;

  if (totsize > 0)
    Debug_Info("%lu bytes reclaimed (pool #%d)\n", totsize, poolno);

  if (poolno > 0)
    poolno--;

#if defined(MEM_STATS)
  /* reinitialize the stats structure for next time through */
  mem_stats_init();
#endif

#endif /* MEM_RECLAIM */
}