=== modified file 'src/window.cpp' --- src/window.cpp 2008-05-09 17:01:51 +0000 +++ src/window.cpp 2008-05-10 11:51:55 +0000 @@ -655,9 +655,17 @@ return (w->original_widget == widget); } -/** Copies 'widget' to 'w->widget' to allow for resizable windows +/** + * Assign widgets to a new window by initialising its widget pointers, and by + * copying the widget array \a widget to \c w->widget to allow for resizable + * windows. * @param w Window on which to attach the widget array - * @param widget pointer of widget array to fill the window with */ + * @param widget pointer of widget array to fill the window with + * + * @post \c w->widget points to allocated memory and contains the copied widget array except for the terminating widget, + * \c w->original_widget points to the original widgets, + * \c w->widget_count contains number of widgets in the allocated memory. + */ void AssignWidgetToWindow(Window *w, const Widget *widget) { w->original_widget = widget; @@ -667,8 +675,9 @@ for (const Widget *wi = widget; wi->type != WWT_LAST; wi++) index++; - w->widget = ReallocT(w->widget, index); - memcpy(w->widget, widget, sizeof(*w->widget) * index); + w->widget = MallocT(index); + memcpy(w->widget, widget, sizeof(Widget) * index); + assert(sizeof(*w->widget) == sizeof(Widget)); w->widget_count = index - 1; } else { w->widget = NULL;