Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31397
Modified Files:
dev_ranger.c
Log Message:
Fixed a bad deallocation that was causing double free's and other problems.
Index: dev_ranger.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/dev_ranger.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dev_ranger.c 20 Sep 2007 23:15:47 -0000 1.3
--- dev_ranger.c 3 Dec 2007 03:06:02 -0000 1.4
***************
*** 116,131 ****
void playerc_ranger_copy_intns_data(playerc_ranger_t *device,
player_ranger_data_intns_t *data)
{
! if(device->intensities != NULL)
! free(device->ranges);
! if((device->intensities = (double *) malloc(data->intensities_count *
sizeof(double))) == NULL)
! {
! device->intensities_count = 0;
! PLAYER_ERROR("Failed to allocate space to store intensity data");
! }
! else
{
! memcpy(device->intensities, data->intensities, data->intensities_count *
sizeof(data->intensities[0]));
! device->intensities_count = data->intensities_count;
}
}
--- 116,135 ----
void playerc_ranger_copy_intns_data(playerc_ranger_t *device,
player_ranger_data_intns_t *data)
{
! if (device->intensities_count != data->intensities_count ||
device->intensities == NULL)
{
! // The number of data has changed, so delete any old data
! if(device->intensities != NULL)
! free(device->intensities);
! // Allocate memory for the new data
! if((device->intensities = (double *) malloc(data->intensities_count *
sizeof(double))) == NULL)
! {
! device->intensities_count = 0;
! PLAYER_ERROR("Failed to allocate space to store intensity data");
! return;
! }
}
+ // Copy the range data
+ memcpy(device->intensities, data->intensities, data->intensities_count *
sizeof(data->intensities[0]));
+ device->intensities_count = data->intensities_count;
}
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit