fix memory leak in layout.cpp
This commit is contained in:
parent
6af3988056
commit
806fc7c3e5
5 changed files with 31 additions and 26 deletions
6
Makefile
6
Makefile
|
@ -14,9 +14,13 @@ lib/libssd1306.a:
|
|||
@mkdir -p lib
|
||||
@cp deps/ssd1306/bld/libssd1306.a lib/libssd1306.a
|
||||
|
||||
flash:
|
||||
flash: avr
|
||||
@make -f avr.Makefile flash
|
||||
|
||||
run: linux
|
||||
@make -f linux.Makefile run
|
||||
|
||||
|
||||
clean:
|
||||
@rm -r build
|
||||
@echo clean all
|
||||
|
|
|
@ -42,3 +42,7 @@ $(OBJDIR):
|
|||
clean:
|
||||
@$(REMOVEDIR) "$(OBJDIR)"
|
||||
@echo clean $(OBJDIR)
|
||||
|
||||
run: $(OBJDIR)/$(TARGET)
|
||||
@echo run $(OBJDIR)/$(TARGET)
|
||||
@$(OBJDIR)/$(TARGET)
|
||||
|
|
|
@ -46,6 +46,8 @@ int layout::expand_(int packedsize) {
|
|||
if (size > slots[i].content->maxsize)
|
||||
size = slots[i].content->maxsize;
|
||||
slots[i].size_ = size;
|
||||
if(slots[i].canvas_)
|
||||
delete slots[i].canvas_;
|
||||
slots[i].canvas_ = new canvas(size, maxheight_);
|
||||
pos += size;
|
||||
}
|
||||
|
|
|
@ -9,15 +9,11 @@
|
|||
#include <stdint.h>
|
||||
#include <hal/hal.h>
|
||||
|
||||
uint8_t *canvasData;
|
||||
NanoCanvas *canvas;
|
||||
uint8_t canvasData[128 * (32 / 8)];
|
||||
NanoCanvas canvas(128, 32, canvasData);
|
||||
|
||||
void hal_init_screen(int w, int h) {
|
||||
ssd1306_128x32_i2c_init();
|
||||
ssd1306_fillScreen( 0x00 );
|
||||
canvasData = new uint8_t[w * (h / 8)];
|
||||
canvas = new NanoCanvas(w, h, canvasData);
|
||||
canvas.clear();
|
||||
|
||||
DDRD = 0;
|
||||
PORTD |= (1 << PC2) | (1 << PC3) | (1 << PC4) | (1 << PC5);
|
||||
|
@ -31,17 +27,16 @@ void hal_draw(int x, int y){
|
|||
void hal_poll_input(bool *ptr) {
|
||||
int in = PIND & 0x3c;
|
||||
|
||||
ptr[0] = in & (1 << PC2);
|
||||
ptr[1] = in & (1 << PC3);
|
||||
ptr[2] = in & (1 << PC4);
|
||||
ptr[3] = in & (1 << PC5);
|
||||
ptr[0] = !(in & (1 << PC2));
|
||||
ptr[1] = !(in & (1 << PC3));
|
||||
ptr[2] = !(in & (1 << PC4));
|
||||
ptr[3] = !(in & (1 << PC5));
|
||||
|
||||
}
|
||||
|
||||
void hal_render() {
|
||||
|
||||
while (true) {
|
||||
canvas.clear();
|
||||
ssd1306_fillScreen( 0x00 );
|
||||
render();
|
||||
canvas.blt(0, 0);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ int main() {
|
|||
|
||||
root = new menu("",
|
||||
new menu("foo",
|
||||
new menu("bar",
|
||||
new menu("baz",
|
||||
new fooValue("I", 5),
|
||||
new fooValue("II", 5),
|
||||
|
@ -42,7 +41,6 @@ int main() {
|
|||
new fooValue("o", 5),
|
||||
new fooValue("oo", 5),
|
||||
new fooValue("o o", 5)
|
||||
)
|
||||
),
|
||||
new menu("x",
|
||||
new fooValue("x x", 5),
|
||||
|
@ -93,6 +91,8 @@ void buttons::onPush(int id, bool state) {
|
|||
l.cursor = c;
|
||||
}
|
||||
break;
|
||||
case I_UP:
|
||||
break;
|
||||
case I_RIGHT:
|
||||
c = l.cursor;
|
||||
if (c = c->getCursor()) {
|
||||
|
|
Loading…
Reference in a new issue