Skip to content

Commit

Permalink
video: ensure that framebuffers are freed on exit
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
  • Loading branch information
tycho committed Apr 20, 2015
1 parent cf355ef commit 293ad67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,27 @@ void Polygon::readVertices(const uint8_t *p, uint16_t zoom) {
}

Video::Video(Resource *resParameter, System *stub)
: res(resParameter), sys(stub) {
: res(resParameter), sys(stub), _videoBase(NULL) {
}

Video::~Video() {
free(_videoBase);
}

void Video::init() {

paletteIdRequested = NO_PALETTE_CHANGE_REQUESTED;

uint8_t* tmp = (uint8_t *)malloc(4*VID_PAGE_SIZE);
memset(tmp,0,4*VID_PAGE_SIZE);
_videoBase = (uint8_t *)malloc(4*VID_PAGE_SIZE);
memset(_videoBase,0,4*VID_PAGE_SIZE);

/*
for (int i = 0; i < 4; ++i) {
_pagePtrs[i] = allocPage();
}
*/
for (int i = 0; i < 4; ++i) {
_pagePtrs[i] = tmp + i * VID_PAGE_SIZE;
_pagePtrs[i] = _videoBase + i * VID_PAGE_SIZE;
}

_curPagePtr3 = getPagePtr(1);
Expand Down
2 changes: 2 additions & 0 deletions video.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Video {


uint8_t paletteIdRequested, currentPaletteId;
uint8_t *_videoBase;
uint8_t *_pagePtrs[4];

// I am almost sure that:
Expand All @@ -85,6 +86,7 @@ struct Video {
uint8_t *_dataBuf;

Video(Resource *res, System *stub);
~Video();
void init();

void setDataBuffer(uint8_t *dataBuf, uint16_t offset);
Expand Down

0 comments on commit 293ad67

Please sign in to comment.