diff options
author | Rami Ylimäki <rami.ylimaki@vincit.fi> | 2011-03-30 16:47:30 +0300 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-04-04 09:55:04 +1000 |
commit | 29d63ba175ff1ef1587c390b18ce61c8f1c150f3 (patch) | |
tree | 09046818824c6f10696f426d044df71807a724eb /xkb/xkbgeom.h | |
parent | f40103cee1d591387359f401a5a7c21f4105aeb4 (diff) |
xkb: Introduce helper function to handle similar reallocations.
This is preparation for a memory leak fix and doesn't contain any
functional changes.
Note that two variables are generally used for reallocation and
clearing of arrays: geom->sz_elems (reallocation) and geom->num_elems
(clearing). The interface of XkbGeomRealloc is deliberately kept
simple and it only accepts geom->sz_elems as argument, because that is
needed to determine whether the array needs to be resized. When the
array is cleared, we just assume that either geom->sz_elems and
geom->num_elems are synchronized to be equal or that unused elements
are cleared whenever geom->num_elems is set to be less than
geom->sz_elems without reallocation.
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'xkb/xkbgeom.h')
-rw-r--r-- | xkb/xkbgeom.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/xkb/xkbgeom.h b/xkb/xkbgeom.h index fe4da3806..d10b956a6 100644 --- a/xkb/xkbgeom.h +++ b/xkb/xkbgeom.h @@ -311,6 +311,17 @@ typedef struct _XkbGeometrySizes { unsigned short num_key_aliases; } XkbGeometrySizesRec,*XkbGeometrySizesPtr; +/** + * Specifies which items should be cleared in an XKB geometry array + * when the array is reallocated. + */ +typedef enum +{ + XKB_GEOM_CLEAR_NONE, /* Don't clear any items, just reallocate. */ + XKB_GEOM_CLEAR_EXCESS, /* Clear new extra items after reallocation. */ + XKB_GEOM_CLEAR_ALL /* Clear all items after reallocation. */ +} XkbGeomClearance; + extern XkbPropertyPtr XkbAddGeomProperty( XkbGeometryPtr /* geom */, @@ -507,6 +518,15 @@ XkbFreeGeometry( Bool /* freeMap */ ); +extern Bool +XkbGeomRealloc( + void ** /* buffer */, + int /* szItems */, + int /* nrItems */, + int /* itemSize */, + XkbGeomClearance /* clearance */ +); + extern Status XkbAllocGeomProps( XkbGeometryPtr /* geom */, |