Jacek Caban : server: Allocate extra_bytes separately from window struct.
Alexandre Julliard
julliard at winehq.org
Wed Feb 9 16:03:49 CST 2022
Module: wine
Branch: master
Commit: 88131e476410fc907c0dc2d0c293ae5ca5f7730b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=88131e476410fc907c0dc2d0c293ae5ca5f7730b
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Feb 8 13:12:10 2022 +0100
server: Allocate extra_bytes separately from window struct.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
server/window.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/server/window.c b/server/window.c
index 7ea91d2a7dc..8fc4022a3ee 100644
--- a/server/window.c
+++ b/server/window.c
@@ -93,7 +93,7 @@ struct window
int prop_alloc; /* number of allocated window properties */
struct property *properties; /* window properties array */
int nb_extra_bytes; /* number of extra bytes */
- char extra_bytes[1]; /* extra bytes storage */
+ char *extra_bytes; /* extra bytes storage */
};
/* flags that can be set by the client */
@@ -483,7 +483,7 @@ static struct window *create_window( struct window *parent, struct window *owner
goto failed;
}
- if (!(win = mem_alloc( sizeof(*win) + extra_bytes - 1 ))) goto failed;
+ if (!(win = mem_alloc( sizeof(*win) ))) goto failed;
if (!(win->handle = alloc_user_handle( win, USER_WINDOW ))) goto failed;
win->parent = parent;
@@ -511,12 +511,19 @@ static struct window *create_window( struct window *parent, struct window *owner
win->prop_inuse = 0;
win->prop_alloc = 0;
win->properties = NULL;
- win->nb_extra_bytes = extra_bytes;
+ win->nb_extra_bytes = 0;
+ win->extra_bytes = NULL;
win->window_rect = win->visible_rect = win->surface_rect = win->client_rect = empty_rect;
- memset( win->extra_bytes, 0, extra_bytes );
list_init( &win->children );
list_init( &win->unlinked );
+ if (extra_bytes)
+ {
+ if (!(win->extra_bytes = mem_alloc( extra_bytes ))) goto failed;
+ memset( win->extra_bytes, 0, extra_bytes );
+ win->nb_extra_bytes = extra_bytes;
+ }
+
/* if parent belongs to a different thread and the window isn't */
/* top-level, attach the two threads */
if (parent && parent->thread && parent->thread != current && !is_desktop_window(parent))
@@ -553,6 +560,7 @@ failed:
if (win)
{
if (win->handle) free_user_handle( win->handle );
+ free( win->extra_bytes );
free( win );
}
release_object( desktop );
@@ -1920,7 +1928,11 @@ void destroy_window( struct window *win )
if (win->update_region) free_region( win->update_region );
if (win->class) release_class( win->class );
free( win->text );
- memset( win, 0x55, sizeof(*win) + win->nb_extra_bytes - 1 );
+ if (win->nb_extra_bytes)
+ {
+ memset( win->extra_bytes, 0x55, win->nb_extra_bytes );
+ free( win->extra_bytes );
+ }
free( win );
}
More information about the wine-cvs
mailing list