File: update_server_frames.C

package info (click to toggle)
peruser 4b33-10
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,944 kB
  • ctags: 1,064
  • sloc: cpp: 22,397; perl: 2,733; makefile: 345; sh: 335
file content (50 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "npconfig.h"

void NP_Config::update_server_frames( int i )
{
   gtk_widget_destroy( server_frames[ i ] );

   int total = subscription.get_total();
   if ( total < 0 )
   {
      subscription.print_error();
      return;
   }

   if ( !total )
   {
      if ( server_frames != NULL )
         free( server_frames );

      server_frames = NULL;
      return;
   }

   GtkWidget **temp_frames;
   if (( temp_frames =
         ( GtkWidget **)calloc( total, sizeof *server_frames )) == NULL )
   {
      perror( "realloc" );
      exit( 1 );
   }
      
   GtkWidget **temp = temp_frames;
   GtkWidget **pointer = server_frames;

   int old_total = total + 1;
   for( int j = 0; j < old_total; ++j )
   {
      if ( j == i )
      {
         ++pointer;
         continue;
      }

      *temp++ = *pointer++;
   }

   free( server_frames );
   server_frames = temp_frames;

   return;
}