forked from vitrine/wmaker
Eliminate the WINGs function WMCreateDataWithBytesNoCopy.
This constructor was only needed in one particular place. We can duplidate the data instead of borrowing it. This ensures that WMData always owns its data segment, which simplifies porting to Rust significantly.
This commit is contained in:
@@ -592,11 +592,6 @@ WMData* WMCreateDataWithLength(unsigned length);
|
||||
|
||||
WMData* WMCreateDataWithBytes(const void *bytes, unsigned length);
|
||||
|
||||
/* destructor is a function called to free the data when releasing the data
|
||||
* object, or NULL if no freeing of data is necesary. */
|
||||
WMData* WMCreateDataWithBytesNoCopy(void *bytes, unsigned length,
|
||||
WMFreeDataProc *destructor);
|
||||
|
||||
WMData* WMCreateDataWithData(WMData *aData);
|
||||
|
||||
WMData* WMRetainData(WMData *aData);
|
||||
|
||||
@@ -78,22 +78,6 @@ WMData *WMCreateDataWithBytes(const void *bytes, unsigned length)
|
||||
return aData;
|
||||
}
|
||||
|
||||
WMData *WMCreateDataWithBytesNoCopy(void *bytes, unsigned length, WMFreeDataProc * destructor)
|
||||
{
|
||||
WMData *aData;
|
||||
|
||||
aData = (WMData *) wmalloc(sizeof(WMData));
|
||||
aData->length = length;
|
||||
aData->capacity = length;
|
||||
aData->growth = length / 2 > 0 ? length / 2 : 1;
|
||||
aData->bytes = bytes;
|
||||
aData->retainCount = 1;
|
||||
aData->format = 0;
|
||||
aData->destructor = destructor;
|
||||
|
||||
return aData;
|
||||
}
|
||||
|
||||
WMData *WMCreateDataWithData(WMData * aData)
|
||||
{
|
||||
WMData *newData;
|
||||
|
||||
+2
-1
@@ -261,8 +261,9 @@ static WMData *getSelectionData(Display * dpy, Window win, Atom where)
|
||||
|
||||
bpi = bits / 8;
|
||||
|
||||
wdata = WMCreateDataWithBytesNoCopy(data, len * bpi, (void *) XFree);
|
||||
wdata = WMCreateDataWithBytes(data, len * bpi);
|
||||
WMSetDataFormat(wdata, bits);
|
||||
XFree(data);
|
||||
|
||||
return wdata;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user