Skip to content

Commit

Permalink
tweak alloca.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed May 20, 2024
1 parent d6c6e88 commit a623d49
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 37 deletions.
11 changes: 11 additions & 0 deletions src/lgfx/internal/alloca.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#if __has_include(<alloca.h>)
#include <alloca.h>
#else
#include <stdlib.h>
#include <malloc.h>
#ifndef alloca
#define alloca _alloca
#endif
#endif
7 changes: 1 addition & 6 deletions src/lgfx/utility/lgfx_qrcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
#include <stdlib.h>
#include <string.h>

#if __has_include(<alloca.h>)
#include <alloca.h>
#elif !defined(alloca)
#include <malloc.h>
#define alloca _alloca
#endif
#include "../internal/alloca.h"

#ifdef max
#undef max
Expand Down
8 changes: 1 addition & 7 deletions src/lgfx/v0/LGFXBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Original Source:
#include "../utility/lgfx_pngle.h" // PNG decode support
#include "../utility/lgfx_qrcode.h" // QR code support
#include "../utility/lgfx_miniz.h"
#include "../internal/alloca.h"

#include <algorithm>
#include <math.h>
Expand All @@ -37,13 +38,6 @@ Original Source:
#include <list>
#include <string>

#if __has_include(<alloca.h>)
#include <alloca.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif

extern "C" {
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
Expand Down
10 changes: 1 addition & 9 deletions src/lgfx/v1/Panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ Original Source:

#include <stdint.h>

#if __has_include("alloca.h")
#include <alloca.h>
#else
#include <malloc.h>
#ifndef alloca
#define alloca _alloca
#endif
#endif

#include "../internal/alloca.h"
#include "misc/enum.hpp"
#include "misc/colortype.hpp"
#include "misc/pixelcopy.hpp"
Expand Down
9 changes: 1 addition & 8 deletions src/lgfx/v1/lgfx_filesystem_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ Original Source:
#include <math.h>
#include <string.h>

#if __has_include("alloca.h")
#include <alloca.h>
#else
#include <malloc.h>
#ifndef alloca
#define alloca _alloca
#endif
#endif
#include "../internal/alloca.h"

namespace lgfx
{
Expand Down
8 changes: 1 addition & 7 deletions src/lgfx/v1/panel/Panel_M5HDMI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Original Source:
#include "../platforms/common.hpp"
#include "../misc/pixelcopy.hpp"
#include "../misc/colortype.hpp"
#include "../../internal/alloca.h"

#include <stdint.h>
#include <stddef.h>
Expand All @@ -35,13 +36,6 @@ Original Source:
#include <hal/gpio_types.h>
#endif

#if __has_include(<alloca.h>)
#include <alloca.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif

#define TAG "M5HDMI"

namespace lgfx
Expand Down

0 comments on commit a623d49

Please sign in to comment.