Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move alloca() definition from all *.h files to one new header file
- Loading branch information
Showing
9 changed files
with
58 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Copyright (c) 2023, MariaDB Corporation. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ | ||
|
||
#ifndef MY_ALLOCA_INCLUDED | ||
#define MY_ALLOCA_INCLUDED | ||
|
||
#ifdef _WIN32 | ||
#include <malloc.h> /*for alloca*/ | ||
/* | ||
MSVC may define "alloca" when compiling in /Ze mode | ||
(with extensions from Microsoft), but otherwise only | ||
the _alloca function is defined: | ||
*/ | ||
#ifndef alloca | ||
#define alloca _alloca | ||
#endif | ||
#else | ||
#ifdef HAVE_ALLOCA_H | ||
#include <alloca.h> | ||
#endif | ||
#endif | ||
|
||
#if defined(HAVE_ALLOCA) | ||
/* | ||
If the GCC/LLVM compiler from the MinGW is used, | ||
alloca may not be defined when using the MSVC CRT: | ||
*/ | ||
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && !defined(alloca) | ||
#define alloca __builtin_alloca | ||
#endif /* GNUC */ | ||
#endif | ||
|
||
#endif /* MY_ALLOCA_INCLUDED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <my_alloca.h> | ||
|
||
#if 0 | ||
extern "C" { | ||
|
1e58b8a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alloca.h is not a standard header file, it may not be available on all platforms and compilers. In addition, the use of alloca is generally discouraged because it can lead to stack overflow or other memory-related issues.
1e58b8a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, covered by
#ifdef HAVE_ALLOCA_H
check.The use of
alloca
in the server is rather limited for this reason. ref: #2321 (comment)