Ticket #11934: 0001-Deskbar-No-need-to-use-dynamic-allocation-remove-unu.2.patch

File 0001-Deskbar-No-need-to-use-dynamic-allocation-remove-unu.2.patch, 2.2 KB (added by Barrett, 9 years ago)
  • src/apps/deskbar/ShowHideMenuItem.cpp

    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.  
    3636
    3737#include "ShowHideMenuItem.h"
    3838
    39 #include <malloc.h>
    40 #include <stdio.h>
    41 #include <strings.h>
    42 
    4339#include <Debug.h>
    4440#include <Roster.h>
    4541#include <WindowInfo.h>
  • src/apps/deskbar/TruncatableMenuItem.cpp

    diff --git a/src/apps/deskbar/TruncatableMenuItem.cpp b/src/apps/deskbar/TruncatableMenuItem.cpp
    index 7b12880..542b4d0 100644
    a b All rights reserved.  
    3737
    3838#include "TruncatableMenuItem.h"
    3939
     40#include <StackOrHeapArray.h>
     41
    4042#include <stdlib.h>
    4143
    4244#include "BarApp.h"
    TTruncatableMenuItem::Label(float width)  
    100102
    101103    const char* label = Label();
    102104    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()) {
    105107            float labelWidth = menu->StringWidth(label);
    106108            float offset = width - labelWidth;
    107109            TruncateLabel(maxWidth - offset, truncatedLabel);
    108110            fTruncatedString.SetTo(truncatedLabel);
    109             free(truncatedLabel);
    110111            return fTruncatedString.String();
    111112        }
    112113    }
  • src/apps/deskbar/WindowMenu.cpp

    diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
    index ce5e948..bbd2673 100644
    a b All rights reserved.  
    3636
    3737#include "WindowMenu.h"
    3838
    39 #include <malloc.h>
    40 #include <stdio.h>
    41 #include <strings.h>
    42 
    4339#include <Catalog.h>
    4440#include <Locale.h>
    4541#include <Window.h>