Update of /cvsroot/playerstage/code/player/libplayertcp
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10946/libplayertcp

Modified Files:
        playertcp.cc playerudp.cc 
Log Message:
applied Toby's patch to replace fixed-size arrays

Index: playerudp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playerudp.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** playerudp.cc        11 Oct 2007 01:39:37 -0000      1.8
--- playerudp.cc        1 Nov 2007 22:16:16 -0000       1.9
***************
*** 606,636 ****
          {
  #if HAVE_ZLIB_H
!           player_map_data_t* raw_data = (player_map_data_t*)payload;
!           zipped_data = 
(player_map_data_t*)calloc(1,sizeof(player_map_data_t));
!           assert(zipped_data);
  
!           // copy the metadata
!           zipped_data->col = raw_data->col;
!           zipped_data->row = raw_data->row;
!           zipped_data->width = raw_data->width;
!           zipped_data->height = raw_data->height;
!           uLongf count = PLAYER_MAP_MAX_TILE_SIZE;
!           assert(count >= compressBound(raw_data->data_count));
  
!           // compress the tile
!           if(compress((Bytef*)zipped_data->data,&count,
!                       (const Bytef*)raw_data->data, raw_data->data_count) != 
Z_OK)
!           {
!             PLAYER_ERROR("failed to compress map data");
!             free(zipped_data);
!             client->writebufferlen = 0;
!             delete msg;
!             return(0);
!           }
  
!           zipped_data->data_count = count;
  
!           // swap the payload pointer to point at the zipped version
!           payload = (void*)zipped_data;
  #else
            PLAYER_WARN("not compressing map data, because zlib was not found 
at compile time");
--- 606,633 ----
          {
  #if HAVE_ZLIB_H
!             player_map_data_t* raw_data = (player_map_data_t*)payload;
!             zipped_data = 
(player_map_data_t*)calloc(1,sizeof(player_map_data_t));
!             assert(zipped_data);
  
!             // copy the metadata
!             *zipped_data = *raw_data;
!             uLongf count = compressBound(raw_data->data_count);
!             zipped_data->data = (int8_t*)malloc(count);
  
!             // compress the tile
!             if(compress((Bytef*)zipped_data->data,&count,
!                         (const Bytef*)raw_data->data, raw_data->data_count) 
!= Z_OK)
!             {
!               PLAYER_ERROR("failed to compress map data");
!               free(zipped_data);
!               client->writebufferlen = 0;
!               delete msg;
!               return(0);
!             }
  
!             zipped_data->data_count = count;
  
!             // swap the payload pointer to point at the zipped version
!             payload = (void*)zipped_data;
  #else
            PLAYER_WARN("not compressing map data, because zlib was not found 
at compile time");
***************
*** 649,652 ****
--- 646,650 ----
            if(zipped_data)
            {
+             free(zipped_data->data);
              free(zipped_data);
              zipped_data=NULL;
***************
*** 670,673 ****
--- 668,672 ----
            if(zipped_data)
            {
+             free(zipped_data->data);
              free(zipped_data);
              zipped_data=NULL;
***************
*** 685,688 ****
--- 684,688 ----
        if(zipped_data)
        {
+         free(zipped_data->data);
          free(zipped_data);
          zipped_data=NULL;
***************
*** 849,853 ****
                raw_data->width = zipped_data->width;
                raw_data->height = zipped_data->height;
!               uLongf count = PLAYER_MAP_MAX_TILE_SIZE;
  
                // uncompress the tile
--- 849,854 ----
                raw_data->width = zipped_data->width;
                raw_data->height = zipped_data->height;
!               uLongf count = 10*zipped_data->data_count;
!               raw_data->data = (int8_t*)calloc(count,sizeof(int8_t));
  
                // uncompress the tile
***************
*** 863,866 ****
--- 864,868 ----
                  device->PutMsg(client->queue, &hdr, raw_data);
                }
+               free(raw_data->data);
                free(raw_data);
  #else

Index: playertcp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playertcp.cc,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** playertcp.cc        11 Oct 2007 01:39:37 -0000      1.66
--- playertcp.cc        1 Nov 2007 22:16:16 -0000       1.67
***************
*** 632,641 ****
  
            // copy the metadata
!           zipped_data->col = raw_data->col;
!           zipped_data->row = raw_data->row;
!           zipped_data->width = raw_data->width;
!           zipped_data->height = raw_data->height;
!           uLongf count = PLAYER_MAP_MAX_TILE_SIZE;
!           assert(count >= compressBound(raw_data->data_count));
  
            // compress the tile
--- 632,638 ----
  
            // copy the metadata
!           *zipped_data = *raw_data;
!           uLongf count = compressBound(raw_data->data_count);
!           zipped_data->data = (int8_t*)malloc(count);
  
            // compress the tile
***************
*** 672,675 ****
--- 669,673 ----
              if(zipped_data)
              {
+               free(zipped_data->data);
                free(zipped_data);
                zipped_data=NULL;
***************
*** 696,699 ****
--- 694,698 ----
            if(zipped_data)
            {
+             free(zipped_data->data);
              free(zipped_data);
              zipped_data=NULL;
***************
*** 711,714 ****
--- 710,714 ----
        if(zipped_data)
        {
+         free(zipped_data->data);
          free(zipped_data);
          zipped_data=NULL;
***************
*** 943,948 ****
                raw_data->width = zipped_data->width;
                raw_data->height = zipped_data->height;
!               uLongf count = PLAYER_MAP_MAX_TILE_SIZE;
! 
                // uncompress the tile
                if(uncompress((Bytef*)raw_data->data,&count,
--- 943,948 ----
                raw_data->width = zipped_data->width;
                raw_data->height = zipped_data->height;
!               uLongf count = 10*zipped_data->data_count;
!               raw_data->data = (int8_t*)calloc(count,sizeof(int8_t));
                // uncompress the tile
                if(uncompress((Bytef*)raw_data->data,&count,
***************
*** 957,960 ****
--- 957,961 ----
                  device->PutMsg(client->queue, &hdr, raw_data);
                }
+               free(raw_data->data);
                free(raw_data);
  #else


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to