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',
|
'pixmap.c',
|
||||||
'privates.c',
|
'privates.c',
|
||||||
'property.c',
|
'property.c',
|
||||||
|
'property_list.c',
|
||||||
'ptrveloc.c',
|
'ptrveloc.c',
|
||||||
'region.c',
|
'region.c',
|
||||||
'registry.c',
|
'registry.c',
|
||||||
|
|
|
@ -341,24 +341,21 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
||||||
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
|
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
|
||||||
if (!pProp)
|
if (!pProp)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
unsigned char *data = calloc(1, totalSize);
|
|
||||||
if (totalSize) {
|
if (totalSize) {
|
||||||
if (!data) {
|
if (!(pProp->data = calloc(1, totalSize))) {
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
dixPropertyFree(pProp);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
memcpy(data, value, totalSize);
|
memcpy(pProp->data, value, totalSize);
|
||||||
}
|
}
|
||||||
pProp->propertyName = property;
|
pProp->propertyName = property;
|
||||||
pProp->type = type;
|
pProp->type = type;
|
||||||
pProp->format = format;
|
pProp->format = format;
|
||||||
pProp->data = data;
|
|
||||||
pProp->size = len;
|
pProp->size = len;
|
||||||
rc = XaceHookPropertyAccess(pClient, pWin, &pProp,
|
rc = XaceHookPropertyAccess(pClient, pWin, &pProp,
|
||||||
DixCreateAccess | DixWriteAccess);
|
DixCreateAccess | DixWriteAccess);
|
||||||
if (rc != Success) {
|
if (rc != Success) {
|
||||||
free(data);
|
dixPropertyFree(pProp);
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
|
||||||
pClient->errorValue = property;
|
pClient->errorValue = property;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -464,8 +461,7 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
|
||||||
|
|
||||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
||||||
notifyVRRMode(client, pWin, PropertyDelete, pProp);
|
notifyVRRMode(client, pWin, PropertyDelete, pProp);
|
||||||
free(pProp->data);
|
dixPropertyFree(pProp);
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -478,8 +474,7 @@ DeleteAllWindowProperties(WindowPtr pWin)
|
||||||
while (pProp) {
|
while (pProp) {
|
||||||
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp);
|
||||||
PropertyPtr pNextProp = pProp->next;
|
PropertyPtr pNextProp = pProp->next;
|
||||||
free(pProp->data);
|
dixPropertyFree(pProp);
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
|
||||||
pProp = pNextProp;
|
pProp = pNextProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,8 +627,7 @@ ProcGetProperty(ClientPtr client)
|
||||||
prevProp->next = pProp->next;
|
prevProp->next = pProp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pProp->data);
|
dixPropertyFree(pProp);
|
||||||
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client->swapped) {
|
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 <X11/X.h>
|
||||||
|
|
||||||
|
#include "include/privates.h"
|
||||||
|
|
||||||
#include "dix.h"
|
#include "dix.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "property.h"
|
#include "property.h"
|
||||||
|
@ -99,4 +101,12 @@ int dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom proprty,
|
||||||
|
|
||||||
void DeleteAllWindowProperties(WindowPtr pWin);
|
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 */
|
#endif /* _XSERVER_PROPERTY_PRIV_H */
|
||||||
|
|
Loading…
Reference in New Issue