Пример #1
0
static void
MoreUdpPairs(
    int num_needed)
{
    int new_max_udp_pairs;
    int i;

    if (num_needed < max_udp_pairs)
	return;

    new_max_udp_pairs = max_udp_pairs * 4;
    while (new_max_udp_pairs < num_needed)
	new_max_udp_pairs *= 4;
    
    if (debug)
	printf("trace: making more space for %d total UDP pairs\n",
	       new_max_udp_pairs);

    /* enlarge array to hold any pairs that we might create */
    utp = ReallocZ(utp,
		   max_udp_pairs * sizeof(udp_pair *),
		   new_max_udp_pairs * sizeof(udp_pair *));

    /* enlarge array to keep track of which ones to ignore */
    ignore_pairs = ReallocZ(ignore_pairs,
			    max_udp_pairs * sizeof(Bool),
			    new_max_udp_pairs * sizeof(Bool));
    if (more_conns_ignored)
	for (i=max_udp_pairs; i < new_max_udp_pairs;++i)
	    ignore_pairs[i] = TRUE;

    max_udp_pairs = new_max_udp_pairs;
}
Пример #2
0
  static void
AddSample(
    struct samples *psamp,
    u_short sample)
{

  /*     printf("AddSample(%d) called\n", sample); */

  /* make sure we have enough space */
  if ((psamp->num_samples+2) > (psamp->max_samples)) {
    u_long new_samples = psamp->max_samples + 100;
    u_short *new_ptr;
    if (psamp->samples) {
      new_ptr = ReallocZ(psamp->samples,
          psamp->max_samples * sizeof(u_short),
          new_samples * sizeof(u_short));
    } else {
      new_ptr = MallocZ(new_samples * sizeof(u_short));
    }
    psamp->max_samples = new_samples;
    psamp->samples = new_ptr;
  }

  /* remember what we did */
  psamp->samples[psamp->num_samples++] = sample;
  if (sample > psamp->max)
    psamp->max = sample;
  if (sample < psamp->max)
    psamp->min = sample;
}
Пример #3
0
  static void
MakeBuckets(
    struct hist *phist,
    u_int num_buckets)
{
  u_long *new_ptr;

  ++num_buckets;  /* 0-based arrays */

  if (num_buckets <= phist->num_buckets)
    return;  /* nothing to do */

  /* round num_buckets up to multiple of 100 */
  if ((num_buckets % 100) != 0) {
    num_buckets = 100 * ((num_buckets+99)/100);
  }

  /* either create the space or expand it */
  if (phist->buckets) {
    new_ptr = ReallocZ(phist->buckets,
        phist->num_buckets * sizeof(u_long),
        num_buckets * sizeof(u_long));
  } else {
    new_ptr = MallocZ(num_buckets * sizeof(u_long));
  }

  /* remember what we did */
  phist->num_buckets = num_buckets;
  phist->buckets = new_ptr;
}
Пример #4
0
static void
plotter_makemore(void)
{
    int new_max_plotters = max_plotters * 4;

    if (debug)
	fprintf(stderr,"plotter: making more space for %d total plotters\n",
		new_max_plotters);

    /* reallocate the memory to make more space */
    pplotters = ReallocZ(pplotters,
			 max_plotters * sizeof(struct plotter_info),
			 new_max_plotters * sizeof(struct plotter_info));

    max_plotters = new_max_plotters;
}