Skip to content

Commit

Permalink
Add overloads for new and delete to avoid linking to libstdc++
Browse files Browse the repository at this point in the history
We could indeed add this library to our pkg-config file, but we don't
use any other of its functions, and using malloc() and free() is more
efficient anyway.
  • Loading branch information
mardy committed Nov 8, 2024
1 parent bfeab3e commit 9a85904
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pixel_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ struct PixelStreamBase {
virtual void write(GXColor color) = 0;
virtual void setup() {}

void *operator new(size_t size) { return malloc(size); }
void operator delete(void * p) { free(p); }

protected:
void *m_data;
int m_width;
Expand Down
3 changes: 3 additions & 0 deletions src/texel.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ struct Texel {
}
}

void *operator new(size_t size) { return malloc(size); }
void operator delete(void * p) { free(p); }

void *m_data;
int m_x;
int m_y;
Expand Down

0 comments on commit 9a85904

Please sign in to comment.