mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-23 08:07:07 +00:00
fix minor leak and avoid inefficient memory reallocation with long properties.
This commit is contained in:
parent
d8c05939b4
commit
0a32e7284e
1 changed files with 20 additions and 18 deletions
38
Tools/xpbs.m
38
Tools/xpbs.m
|
@ -720,7 +720,6 @@ static int xFixesEventBase;
|
|||
}
|
||||
else if ([type isEqual: NSFilenamesPboardType])
|
||||
{
|
||||
|
||||
[self requestData: XG_FILE_NAME];
|
||||
}
|
||||
else if ([type isEqual: NSRTFPboardType])
|
||||
|
@ -942,26 +941,29 @@ xErrorHandler(Display *d, XErrorEvent *e)
|
|||
|
||||
if (md == nil)
|
||||
{
|
||||
md = [[NSMutableData alloc] initWithBytes: (void *)data
|
||||
length: count];
|
||||
/* data buffer needs to be big enough for the whole property
|
||||
*/
|
||||
md = [[NSMutableData alloc]
|
||||
initWithCapacity: count + bytes_remaining];
|
||||
req_type = actual_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (req_type != actual_type)
|
||||
{
|
||||
char *req_name = XGetAtomName(xDisplay, req_type);
|
||||
char *act_name = XGetAtomName(xDisplay, actual_type);
|
||||
|
||||
NSLog(@"Selection changed type from %s to %s.",
|
||||
req_name, act_name);
|
||||
XFree(req_name);
|
||||
XFree(act_name);
|
||||
RELEASE(md);
|
||||
return nil;
|
||||
}
|
||||
[md appendBytes: (void *)data length: count];
|
||||
else if (req_type != actual_type)
|
||||
{
|
||||
char *req_name = XGetAtomName(xDisplay, req_type);
|
||||
char *act_name = XGetAtomName(xDisplay, actual_type);
|
||||
|
||||
NSLog(@"Selection changed type from %s to %s.",
|
||||
req_name, act_name);
|
||||
XFree(req_name);
|
||||
XFree(act_name);
|
||||
RELEASE(md);
|
||||
if (data)
|
||||
{
|
||||
XFree(data);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
[md appendBytes: (void *)data length: count];
|
||||
|
||||
long_offset += count / 4;
|
||||
if (data)
|
||||
|
|
Loading…
Reference in a new issue