コード例 #1
0
ファイル: free.c プロジェクト: wbx-github/uclibc-ng
/*
  Initialize a malloc_state struct.

  This is called only from within __malloc_consolidate, which needs
  be called in the same contexts anyway.  It is never called directly
  outside of __malloc_consolidate because some optimizing compilers try
  to inline it at all call points, which turns out not to be an
  optimization at all. (Inlining it in __malloc_consolidate is fine though.)
*/
static void malloc_init_state(mstate av)
{
    int     i;
    mbinptr bin;

    /* Establish circular links for normal bins */
    for (i = 1; i < NBINS; ++i) {
	bin = bin_at(av,i);
	bin->fd = bin->bk = bin;
    }

    av->top_pad        = DEFAULT_TOP_PAD;
    av->n_mmaps_max    = DEFAULT_MMAP_MAX;
    av->mmap_threshold = DEFAULT_MMAP_THRESHOLD;
    av->trim_threshold = DEFAULT_TRIM_THRESHOLD;

#if MORECORE_CONTIGUOUS
    set_contiguous(av);
#else
    set_noncontiguous(av);
#endif


    set_max_fast(av, DEFAULT_MXFAST);

    av->top            = initial_top(av);
    av->pagesize       = malloc_getpagesize;
}
コード例 #2
0
ファイル: metachunk.cpp プロジェクト: campolake/openjdk9
void Metachunk::mangle(juint word_value) {
  // Overwrite the payload of the chunk and not the links that
  // maintain list of chunks.
  HeapWord* start = (HeapWord*)initial_top();
  size_t size = word_size() - overhead();
  Copy::fill_to_words(start, size, word_value);
}
コード例 #3
0
ファイル: metachunk.cpp プロジェクト: campolake/openjdk9
Metachunk::Metachunk(size_t word_size,
                     VirtualSpaceNode* container)
    : Metabase<Metachunk>(word_size),
    _top(NULL),
    _container(container)
{
  _top = initial_top();
#ifdef ASSERT
  set_is_tagged_free(false);
  mangle(uninitMetaWordVal);
#endif
}
コード例 #4
0
ファイル: hooks.c プロジェクト: AdvancedC/glibc
static int
internal_function
top_check(void)
{
  mchunkptr t = top(&main_arena);
  char* brk, * new_brk;
  INTERNAL_SIZE_T front_misalign, sbrk_size;
  unsigned long pagesz = GLRO(dl_pagesize);

  if (t == initial_top(&main_arena) ||
      (!chunk_is_mmapped(t) &&
       chunksize(t)>=MINSIZE &&
       prev_inuse(t) &&
       (!contiguous(&main_arena) ||
	(char*)t + chunksize(t) == mp_.sbrk_base + main_arena.system_mem)))
    return 0;

  malloc_printerr (check_action, "malloc: top chunk is corrupt", t);

  /* Try to set up a new top chunk. */
  brk = MORECORE(0);
  front_misalign = (unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK;
  if (front_misalign > 0)
    front_misalign = MALLOC_ALIGNMENT - front_misalign;
  sbrk_size = front_misalign + mp_.top_pad + MINSIZE;
  sbrk_size += pagesz - ((unsigned long)(brk + sbrk_size) & (pagesz - 1));
  new_brk = (char*)(MORECORE (sbrk_size));
  if (new_brk == (char*)(MORECORE_FAILURE))
    {
      __set_errno (ENOMEM);
      return -1;
    }
  /* Call the `morecore' hook if necessary.  */
  void (*hook) (void) = force_reg (__after_morecore_hook);
  if (hook)
    (*hook) ();
  main_arena.system_mem = (new_brk - mp_.sbrk_base) + sbrk_size;

  top(&main_arena) = (mchunkptr)(brk + front_misalign);
  set_head(top(&main_arena), (sbrk_size - front_misalign) | PREV_INUSE);

  return 0;
}
コード例 #5
0
ファイル: monitorWindow.cpp プロジェクト: AaronNGray/self
bool MonitorWindow::open_and_resize(Monitor* m) {
  _m = m;
  
  pw = 0;
# ifdef QUARTZ_LIB
  if (!SpyDisplay[0]) {
    pw = (AbstractPlatformWindow*) new QuartzWindow;
  }
# endif
  
# ifdef XLIB
  if (!pw) {
    pw = (AbstractPlatformWindow*) new XPlatformWindow;
  }
# endif
  
  if (!pw) {
    warning("no window system for spy");
    return false;
  }
  
  // open the window, and resize for the spy
  // set size hints to don't care cause we will resize window below
  if (!  pw->open( compute_display_name(),
                  100, 100, 500, 500,
                  -1,  -1,  -1,  -1,
                  compute_window_name(),
                  "Spy",
                  SpyFont[0] ? SpyFont : pw->default_fixed_font_name(),
                  pw->default_fixed_font_size()))
    return false;
  
  // Spy uses fixed-width font and sizes window accordingly.
  // On some platforms, cannot get font till window is open.
  // So, now that window is opened, can ask spy for height, and
  // can set window place/size and size limits.
  if (!pw->change_extent( initial_left(), initial_top(), initial_width(), initial_height()))  { close();  return false; }
  if (!pw->change_size_hints( -1,  initial_width(), initial_height(), initial_height()))       { close();  return false; }
  return true;
}