using Toybox.Application as App;
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
class MallocApp extends App.AppBase {
function getInitialView() {
return [ new MallocView(), new MallocDelegate() ];
}
}
class MallocView extends Ui.View {
function onUpdate(dc) {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();
dc.drawText(dc.getWidth()/2,dc.getHeight()/2,
Gfx.FONT_LARGE, "Malloc View", Gfx.TEXT_JUSTIFY_CENTER);
}
}
class Malloc {
var mAlloc = new [1000];
var mFunc;
function initialize(){
mFunc = method(:doNothing);
}
function doNothing(){
}
}
class Mfree {
var mAlloc = new [1000];
var mFunc;
function initialize(){
mFunc = null;
}
function doNothing(){
}
}
class MallocDelegate extends Ui.InputDelegate {
function onKey(event){
var key = event.getKey();
if(Ui.KEY_ENTER == key){
Sys.println("Enter = add KB's");
var myClass = new Malloc();
}
else if(key == Ui.KEY_ESC){
Sys.println("Esc = don't add KB's");
var myClass = new Mfree();
}
}
}