# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1659393991 0 # Node ID 4521f014bb179c36d7b2917595ef7301a9a530b5 # Parent 1efe0ed76629ad40176aef47cd5b2309fe533b1a Fix some memory leaks reported by Xcode's Instruments. diff -r 1efe0ed76629 -r 4521f014bb17 dwtest.c --- a/dwtest.c Mon Aug 01 22:09:46 2022 +0000 +++ b/dwtest.c Mon Aug 01 22:46:31 2022 +0000 @@ -1235,6 +1235,8 @@ dw_pixmap_set_transparent_color(image, DW_CLR_WHITE); dw_messagebox(utf8string ? utf8string : "DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); + if(utf8string) + dw_free(utf8string); dw_draw_rect(0, text1pm, DW_DRAW_FILL | DW_DRAW_NOAA, 0, 0, font_width*width1, font_height*rows); dw_draw_rect(0, text2pm, DW_DRAW_FILL | DW_DRAW_NOAA, 0, 0, font_width*cols, font_height*rows); dw_signal_connect(textbox1, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(context_menu_event), NULL); diff -r 1efe0ed76629 -r 4521f014bb17 mac/dw.m --- a/mac/dw.m Mon Aug 01 22:09:46 2022 +0000 +++ b/mac/dw.m Mon Aug 01 22:46:31 2022 +0000 @@ -3108,7 +3108,7 @@ } -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; } -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; } --(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [scrollview release]; [super dealloc]; } +-(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [self clear]; [scrollview release]; [super dealloc]; } @end /* Dive into the tree freeing all desired child nodes */ @@ -6398,17 +6398,18 @@ DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, const char *, startpoint, int) { DW_FUNCTION_INIT; + DW_LOCAL_POOL_IN; DWMLE *mle = handle; unsigned int retval; NSTextStorage *ts = [mle textStorage]; NSString *nstr = [NSString stringWithUTF8String:buffer]; NSColor *fgcolor = [ts foregroundColor]; NSFont *font = [ts font]; - NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes setObject:(fgcolor ? fgcolor : [NSColor textColor]) forKey:NSForegroundColorAttributeName]; if(font) [attributes setObject:font forKey:NSFontAttributeName]; - NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes]; + NSAttributedString *nastr = [[[NSAttributedString alloc] initWithString:nstr attributes:attributes] autorelease]; NSUInteger length = [ts length]; if(startpoint < 0) startpoint = 0; @@ -6416,6 +6417,7 @@ startpoint = (int)length; [ts insertAttributedString:nastr atIndex:startpoint]; retval = (unsigned int)strlen(buffer) + startpoint; + DW_LOCAL_POOL_OUT; DW_FUNCTION_RETURN_THIS(retval); }