dix: add dixPropertyFree()
This function should be used for free'ing an individual Property structure, along with associated data. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
628e36226c
commit
07d67a07e2
|
@ -24,6 +24,7 @@ srcs_dix = [
|
|||
'pixmap.c',
|
||||
'privates.c',
|
||||
'property.c',
|
||||
'property_list.c',
|
||||
'ptrveloc.c',
|
||||
'region.c',
|
||||
'registry.c',
|
||||
|
|
|
@ -341,24 +341,21 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
|||
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
|
||||
if (!pProp)
|
||||
return BadAlloc;
|
||||
unsigned char *data = calloc(1, totalSize);
|
||||
if (totalSize) {
|
||||
if (!data) {
|
||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||
if (!(pProp->data = calloc(1, totalSize))) {
|
||||
dixPropertyFree(pProp);
|
||||
return BadAlloc;
|
||||
}
|
||||
memcpy(data, value, totalSize);
|
||||
memcpy(pProp->data, value, totalSize);
|
||||
}
|
||||
pProp->propertyName = property;
|
||||
pProp->type = type;
|
||||
pProp->format = format;
|
||||
pProp->data = data;
|
||||
pProp->size = len;
|
||||
rc = XaceHookPropertyAccess(pClient, pWin, &pProp,
|
||||
DixCreateAccess | DixWriteAccess);
|
||||
if (rc != Success) {
|
||||
free(data);
|
||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||
dixPropertyFree(pProp);
|
||||
pClient->errorValue = property;
|
||||
return rc;
|
||||
}
|
||||
|
@ -464,8 +461,7 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
|
|||
|
||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
||||
notifyVRRMode(client, pWin, PropertyDelete, pProp);
|
||||
free(pProp->data);
|
||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||
dixPropertyFree(pProp);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -478,8 +474,7 @@ DeleteAllWindowProperties(WindowPtr pWin)
|
|||
while (pProp) {
|
||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
||||
PropertyPtr pNextProp = pProp->next;
|
||||
free(pProp->data);
|
||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||
dixPropertyFree(pProp);
|
||||
pProp = pNextProp;
|
||||
}
|
||||
|
||||
|
@ -632,8 +627,7 @@ ProcGetProperty(ClientPtr client)
|
|||
prevProp->next = pProp->next;
|
||||
}
|
||||
|
||||
free(pProp->data);
|
||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
||||
dixPropertyFree(pProp);
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
||||
*/
|
||||
#include <dix-config.h>
|
||||
|
||||
#include "dix/property_priv.h"
|
||||
#include "include/privates.h"
|
||||
#include "include/propertyst.h"
|
||||
|
||||
void dixPropertyFree(PropertyPtr pr)
|
||||
{
|
||||
if (pr) {
|
||||
free(pr->data);
|
||||
dixFreeObjectWithPrivates(pr, PRIVATE_PROPERTY);
|
||||
}
|
||||
}
|
|
@ -53,6 +53,8 @@ SOFTWARE.
|
|||
|
||||
#include <X11/X.h>
|
||||
|
||||
#include "include/privates.h"
|
||||
|
||||
#include "dix.h"
|
||||
#include "window.h"
|
||||
#include "property.h"
|
||||
|
@ -99,4 +101,12 @@ int dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom proprty,
|
|||
|
||||
void DeleteAllWindowProperties(WindowPtr pWin);
|
||||
|
||||
/*
|
||||
* Free an individual property structure and related data.
|
||||
* Invalidates the passed pointer. Doesn't touch anything other in the list.
|
||||
*
|
||||
* @param pProp pointer to property structure to free
|
||||
*/
|
||||
void dixPropertyFree(PropertyPtr pProp);
|
||||
|
||||
#endif /* _XSERVER_PROPERTY_PRIV_H */
|
||||
|
|
Loading…
Reference in New Issue