From 96ef527b0c9e34d7725390c6da8abf1baeffc8d7 Mon Sep 17 00:00:00 2001
From: Dario Casalinuovo <b.vitruvio@gmail.com>
Date: Thu, 2 Apr 2015 10:14:44 +0200
Subject: [PATCH 1/3] Deskbar: No need to use dynamic allocation, remove unused
headers.
---
src/apps/deskbar/ShowHideMenuItem.cpp | 4 ----
src/apps/deskbar/TruncatableMenuItem.cpp | 7 ++++---
src/apps/deskbar/WindowMenu.cpp | 4 ----
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/apps/deskbar/ShowHideMenuItem.cpp b/src/apps/deskbar/ShowHideMenuItem.cpp
index de39e2f..28f7a09 100644
a
|
b
|
All rights reserved.
|
36 | 36 | |
37 | 37 | #include "ShowHideMenuItem.h" |
38 | 38 | |
39 | | #include <malloc.h> |
40 | | #include <stdio.h> |
41 | | #include <strings.h> |
42 | | |
43 | 39 | #include <Debug.h> |
44 | 40 | #include <Roster.h> |
45 | 41 | #include <WindowInfo.h> |
diff --git a/src/apps/deskbar/TruncatableMenuItem.cpp b/src/apps/deskbar/TruncatableMenuItem.cpp
index 7b12880..542b4d0 100644
a
|
b
|
All rights reserved.
|
37 | 37 | |
38 | 38 | #include "TruncatableMenuItem.h" |
39 | 39 | |
| 40 | #include <StackOrHeapArray.h> |
| 41 | |
40 | 42 | #include <stdlib.h> |
41 | 43 | |
42 | 44 | #include "BarApp.h" |
… |
… |
TTruncatableMenuItem::Label(float width)
|
100 | 102 | |
101 | 103 | const char* label = Label(); |
102 | 104 | if (width > 0 && maxWidth > 0 && width > maxWidth) { |
103 | | char* truncatedLabel = (char*)malloc(strlen(label) + 4); |
104 | | if (truncatedLabel != NULL) { |
| 105 | BStackOrHeapArray<char, 128> truncatedLabel(strlen(label) + 4); |
| 106 | if (truncatedLabel.IsValid()) { |
105 | 107 | float labelWidth = menu->StringWidth(label); |
106 | 108 | float offset = width - labelWidth; |
107 | 109 | TruncateLabel(maxWidth - offset, truncatedLabel); |
108 | 110 | fTruncatedString.SetTo(truncatedLabel); |
109 | | free(truncatedLabel); |
110 | 111 | return fTruncatedString.String(); |
111 | 112 | } |
112 | 113 | } |
diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
index ce5e948..bbd2673 100644
a
|
b
|
All rights reserved.
|
36 | 36 | |
37 | 37 | #include "WindowMenu.h" |
38 | 38 | |
39 | | #include <malloc.h> |
40 | | #include <stdio.h> |
41 | | #include <strings.h> |
42 | | |
43 | 39 | #include <Catalog.h> |
44 | 40 | #include <Locale.h> |
45 | 41 | #include <Window.h> |