Subversion Repositories spk

Rev

Rev 229 | Rev 317 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 229 Rev 308
Line 1040... Line 1040...
1040
	ubound=deflateBound(&zs, (unsigned long)size);
1040
	ubound=deflateBound(&zs, (unsigned long)size);
1041
	if ( newsize < ubound)
1041
	if ( newsize < ubound)
1042
	{
1042
	{
1043
		newsize += ubound;
1043
		newsize += ubound;
1044
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
1044
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
-
 
1045
		if (!data)
-
 
1046
			return nullptr;
1045
	}
1047
	}
1046
 
1048
 
1047
 
1049
 
1048
	zs.next_out=d;
1050
	zs.next_out=d;
1049
	zs.avail_out=(unsigned int)newsize - pos;
1051
	zs.avail_out=(unsigned int)newsize - pos;
1050
 
1052
 
1051
	while((ret=deflate(&zs, Z_FINISH))==Z_OK)
1053
	while((ret=deflate(&zs, Z_FINISH))==Z_OK)
1052
	{
1054
	{
1053
		newsize += 1024;
1055
		newsize += 1024;
1054
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
1056
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
-
 
1057
		if (!data)
-
 
1058
			return nullptr;
1055
		zs.next_out=data + zs.total_out;
1059
		zs.next_out=data + zs.total_out;
1056
		zs.avail_out=(unsigned int)newsize - zs.total_out;
1060
		zs.avail_out=(unsigned int)newsize - zs.total_out;
1057
	}
1061
	}
1058
	pos += zs.total_out;
1062
	pos += zs.total_out;
1059
 
1063
 
Line 1065... Line 1069...
1065
	int s = sizeof(crc) + sizeof(size);
1069
	int s = sizeof(crc) + sizeof(size);
1066
	if ( newsize < (size_t)(s + pos) )
1070
	if ( newsize < (size_t)(s + pos) )
1067
	{
1071
	{
1068
		newsize += (s + pos) - newsize;
1072
		newsize += (s + pos) - newsize;
1069
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
1073
		data = (unsigned char *)realloc ( data, sizeof(unsigned char) * newsize );
-
 
1074
		if (!data)
-
 
1075
			return nullptr;
1070
	}
1076
	}
-
 
1077
 
-
 
1078
	unsigned long lSize = static_cast<unsigned long>(size);
1071
 
1079
 
1072
	memcpy(&data[pos], &crc, sizeof(crc));
1080
	memcpy(&data[pos], &crc, sizeof(crc));
1073
	pos += sizeof(crc);
1081
	pos += sizeof(crc);
1074
	memcpy(&data[pos], &size, sizeof(size));
1082
	memcpy(&data[pos], &lSize, sizeof(lSize));
1075
	pos += sizeof(size);
1083
	pos += sizeof(lSize);
1076
 
1084
 
1077
	newsize = pos;
1085
	newsize = pos;
1078
 
1086
 
1079
	unsigned char *retdata = NULL;
1087
	unsigned char *retdata = NULL;
1080
	if ( ret == Z_STREAM_END )
1088
	if ( ret == Z_STREAM_END )