conform usage of alloca function

This commit is contained in:
Ianos Gnatiuc 2005-10-11 01:54:40 +00:00
parent 76bec88bc0
commit cbde69e90a
12 changed files with 67 additions and 58 deletions

View File

@ -24,10 +24,6 @@
// Arealist functions.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#if defined(_MSC_VER)
/* C4786: 'identifier' : identifier was truncated to 'number'
characters in the debug information
@ -37,6 +33,10 @@
#include <algorithm>
#include <golded.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
@ -481,7 +481,7 @@ void SelMaskPick::close() {
void SelMaskPick::print_line(uint idx, uint pos, bool isbar) {
#if defined(__WIN32__)
#if defined(__USE_ALLOCA__)
char *buf = (char*)alloca(DESC_LEN+3);
#else
__extension__ char buf[DESC_LEN+3];

View File

@ -24,15 +24,15 @@
// The Internal Editor (IE), part 2.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#include <golded.h>
#include <geedit.h>
#include <gutlcode.h>
#include <gutlclip.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
// Constructor
@ -1090,7 +1090,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
else {
int tabsz = CFG->disptabsize ? CFG->disptabsize : 1;
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
char *spaces = (char*)alloca(tabsz+1);
#else
__extension__ char spaces[tabsz+1];

View File

@ -24,14 +24,15 @@
// OS/2 clipboard to/from edit paste buffer.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#include <golded.h>
#include <geedit.h>
#include <gutlclip.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
void IEclass::Clip2Buf() {
gclipbrd clipbrd;
@ -40,7 +41,7 @@ void IEclass::Clip2Buf() {
return;
int tabsz = CFG->disptabsize ? CFG->disptabsize : 1;
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
char *spaces = (char*)alloca(tabsz+1);
#else
__extension__ char spaces[tabsz+1];

View File

@ -24,15 +24,15 @@
// File handling.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#include <fcntl.h>
#include <golded.h>
#include <gwildmat.h>
#include <gdirposx.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
@ -777,7 +777,7 @@ void FileRequest(GMsg* msg) {
else
ptr1 = ptr2;
ptr2 = strskip_txt(ptr1);
#if defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
char *tmpbuf = (char*)alloca(ptr2-ptr1+1);
#else
__extension__ char tmpbuf[ptr2-ptr1+1];
@ -819,7 +819,7 @@ void FileRequest(GMsg* msg) {
if(txtptr[16] == '/' and txtptr[19] == '/' and txtptr[24] == '(' /*)*/) {
ptr1 = strskip_wht(txtptr);
ptr2 = strskip_txt(ptr1);
#if defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
char *tmpbuf = (char*)alloca(ptr2-ptr1+1);
#else
__extension__ char tmpbuf[ptr2-ptr1+1];
@ -955,7 +955,7 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1();
ptr = freqfile[n]+1; // 01234567890123456
ptr2 = strskip_txt(ptr);
#if defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
char *tmpbuf = (char*)alloca(ptr2-ptr+1);
#else
__extension__ char tmpbuf[ptr2-ptr+1];
@ -978,7 +978,7 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1();
ptr = freqfile[crsr]+1; // 01234567890123456
ptr2 = strskip_txt(ptr);
#if defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
char *tmpbuf = (char*)alloca(ptr2-ptr+1);
#else
__extension__ char tmpbuf[ptr2-ptr+1];

View File

@ -24,13 +24,13 @@
// Header edit.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#include <golded.h>
#include <gwinput.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
@ -322,7 +322,7 @@ bool GMsgHeaderEdit::validate() {
bool res = set_to_address(msg, &toname, &toaddr, &fromaddr, &subj, 0, LNG->SelectDestNode, lookup);
vcurshow();
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
size_t bot2size = EDIT->HdrNodeLen()+1;
char *bot2 = (char*)alloca(bot2size);
MakeAttrStr(bot2, bot2size, &msg->attr);

View File

@ -24,16 +24,17 @@
// Conversion of a raw message to a linked list of lines.
// ------------------------------------------------------------------
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
#include <cstdarg>
#include <golded.h>
#include <gstrmail.h>
#include <gutlcode.h>
#include <ghdrmime.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
#ifdef __UNIX__
@ -1391,7 +1392,7 @@ int ScanLine(GMsg* msg, Line* line, const char* ptr, int getvalue, int mask) {
ptr++;
char endchar = *ptr;
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
char *kludge = (char*)alloca(ptr-kludge1+1);
#else
__extension__ char kludge[ptr-kludge1+1];

View File

@ -24,15 +24,16 @@
// Message lister.
// ------------------------------------------------------------------
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
#include <golded.h>
#include <gcharset.h>
#include <iostream>
#include <iomanip>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
extern GMsg* reader_msg;
@ -841,7 +842,7 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
char buf[256];
ulong maxlev = (100*window.width()+h_offset+1)/2;
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
char *buf2 = (char*)alloca(maxlev*2+2);
#else
__extension__ char buf2[maxlev*2+2];

View File

@ -24,14 +24,15 @@
// Misc. msg handling.
// ------------------------------------------------------------------
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
#include <cstdarg>
#include <golded.h>
#include <gtimall.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
static bool tokenxchg(char*& dst, char* tok, const char* src, int len = 0, int cnt = 0, ...) {
@ -488,7 +489,7 @@ void LoadText(GMsg* msg, const char* textfile) {
buf = (char*)throw_malloc(PBUFSIZE);
int tabsz = CFG->disptabsize ? CFG->disptabsize : 1;
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
char *spaces = (char*)alloca(tabsz+1);
#else
__extension__ char spaces[tabsz+1];

View File

@ -24,10 +24,6 @@
// Template handling.
// ------------------------------------------------------------------
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <malloc.h>
#endif
#if defined(_MSC_VER)
/* C4786: 'identifier' : identifier was truncated to 'number'
characters in the debug information
@ -37,6 +33,10 @@
#include <algorithm>
#include <golded.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
@ -87,7 +87,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
uint ctrlinfo;
char textfile[GMAXPATH];
char indexfile[GMAXPATH];
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(__USE_ALLOCA__)
size_t sizeofbuf = CFG->quotemargin + 256;
char *buf = (char*)alloca(sizeofbuf);
#else

View File

@ -24,12 +24,13 @@
// Message viewer class implementation.
// ------------------------------------------------------------------
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <golded.h>
#include <gutlos.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
#include <golded.h>
#include <gutlos.h>
// ------------------------------------------------------------------
@ -111,7 +112,7 @@ void GMsgHeaderView::Paint() {
else
*buf1 = NUL;
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(__USE_ALLOCA__)
char *top = (char*)alloca(width+1);
#else
__extension__ char top[width+1];

View File

@ -110,6 +110,9 @@
#define __HAVE_DRIVES__
#endif
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __USE_ALLOCA__
#endif
/* --------------------------------------------------------------- */
/* System-wide constants */

View File

@ -26,8 +26,9 @@
#include <gstrall.h>
#include <gwildmat.h>
#ifdef _MSC_VER
#include <malloc.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
@ -45,9 +46,9 @@
**
** Special thanks to Lars Mathiesen <thorinn@diku.dk> for the ABORT code.
** This can greatly speed up failing wildcard patterns. For example:
** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-*
** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1
** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1
** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-*
** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1
** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1
** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without
** the ABORT code, it takes 22310 calls to fail. Ugh. The following
** explanation is from Lars:
@ -167,7 +168,7 @@ bool strwild(const char* str, const char* wild) {
if(wild[1] == NUL)
return true;
else {
#ifdef _MSC_VER
#if defined(__USE_ALLOCA__)
char *buf = (char *)alloca(strlen(wild));
#else
__extension__ char buf[strlen(wild)];