Exemple #1
0
/**
 * pango_tab_array_new:
 * @initial_size: Initial number of tab stops to allocate, can be 0
 * @positions_in_pixels: whether positions are in pixel units
 *
 * Creates an array of @initial_size tab stops. Tab stops are specified in
 * pixel units if @positions_in_pixels is %TRUE, otherwise in Pango
 * units. All stops are initially at position 0.
 *
 * Return value: the newly allocated #PangoTabArray, which should
 *               be freed with pango_tab_array_free().
 **/
PangoTabArray*
pango_tab_array_new (gint initial_size,
		     gboolean positions_in_pixels)
{
  PangoTabArray *array;

  g_return_val_if_fail (initial_size >= 0, NULL);

  /* alloc enough to treat array->tabs as an array of length
   * size, though it's declared as an array of length 1.
   * If we allowed tab array resizing we'd need to drop this
   * optimization.
   */
  array = g_slice_new (PangoTabArray);
  array->size = initial_size;
  array->allocated = initial_size;

  if (array->allocated > 0)
    {
      array->tabs = g_new (PangoTab, array->allocated);
      init_tabs (array, 0, array->allocated);
    }
  else
    array->tabs = NULL;

  array->positions_in_pixels = positions_in_pixels;

  return array;
}
/*
**		Init every attributes of the player.
*/
int		init_player(int const fd, t_player *p,
			    int const connect_nbr)
{
  p->lvl = DEFAULT_LVL;
  p->rising = 0;
  p->target_dir = -1;
  p->target_pid = 0;
  p->look_for_target = 0;
  p->people_needed = 1;
  p->last_move = TURN_LEFT;
  p->look_around = 0;
  p->waiting_answer = 0;
  p->waiting_time = 0;
  p->wait_before_broadcast = 0;
  p->need_to_broadcast = 0;
  p->nbr_broadcasts = 0;
  p->nbr_broadcast_emitted = 0;
  p->preparing_to_rise = 0;
  p->need_to_kick = 0;
  if ((p->pid = getpid()) <= 0)
    return (0);
  init_tabs(p);
  p->need_to_look_stuff = UPDATE_STUFF_TIME;
  init_requirements(p->requirements);
  return (init_player_actions(fd, p, connect_nbr));
}
Exemple #3
0
/**
 * pango_tab_array_resize:
 * @tab_array: a #PangoTabArray
 * @new_size: new size of the array
 *
 * Resizes a tab array. You must subsequently initialize any tabs that
 * were added as a result of growing the array.
 *
 **/
void
pango_tab_array_resize (PangoTabArray *tab_array,
			gint           new_size)
{
  if (new_size > tab_array->allocated)
    {
      gint current_end = tab_array->allocated;

      /* Ratchet allocated size up above the index. */
      if (tab_array->allocated == 0)
	tab_array->allocated = 2;

      while (new_size > tab_array->allocated)
	tab_array->allocated = tab_array->allocated * 2;

      tab_array->tabs = g_renew (PangoTab, tab_array->tabs,
				 tab_array->allocated);

      init_tabs (tab_array, current_end, tab_array->allocated);
    }

  tab_array->size = new_size;
}