Commit 0055e1a5 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.2' into 10.2

parents 37dd3cf4 b6563d77
...@@ -61,7 +61,7 @@ IF(UNIX) ...@@ -61,7 +61,7 @@ IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -fexceptions -fPIC ") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -fexceptions -fPIC ")
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} inihandl.c) SET(CONNECT_SOURCES ${CONNECT_SOURCES} inihandl.cpp)
SET(IPHLPAPI_LIBRARY "") SET(IPHLPAPI_LIBRARY "")
ELSE(NOT UNIX) ELSE(NOT UNIX)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} SET(CONNECT_SOURCES ${CONNECT_SOURCES}
......
...@@ -217,7 +217,8 @@ DllExport int PlugExit(PGLOBAL); // Plug global termination ...@@ -217,7 +217,8 @@ DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport bool AllocSarea(PGLOBAL, uint);
DllExport void FreeSarea(PGLOBAL);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport char *PlugDup(PGLOBAL g, const char *str);
......
...@@ -3009,7 +3009,9 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) ...@@ -3009,7 +3009,9 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
return NULL; return NULL;
if (!x) { if (!x) {
const char *p;
char *s = (ishav) ? havg : body; char *s = (ishav) ? havg : body;
uint j, k, n;
// Append the value to the filter // Append the value to the filter
switch (args[i]->field_type()) { switch (args[i]->field_type()) {
...@@ -3065,16 +3067,38 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) ...@@ -3065,16 +3067,38 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
strcat(s, "'}"); strcat(s, "'}");
break; break;
default: default:
strcat(s, "'"); j = strlen(s);
strncat(s, res->ptr(), res->length()); s[j++] = '\'';
strcat(s, "'"); p = res->ptr();
} // endswitch field type n = res->length();
for (k = 0; k < n; k++) {
if (p[k] == '\'')
s[j++] = '\'';
s[j++] = p[k];
} // endfor k
s[j++] = '\'';
s[j] = 0;
} // endswitch field type
} else { } else {
strcat(s, "'"); j = strlen(s);
strncat(s, res->ptr(), res->length()); s[j++] = '\'';
strcat(s, "'"); p = res->ptr();
} // endif tty n = res->length();
for (k = 0; k < n; k++) {
if (p[k] == '\'')
s[j++] = '\'';
s[j++] = p[k];
} // endfor k
s[j++] = '\'';
s[j] = 0;
} // endif tty
break; break;
default: default:
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
// The types and variables used locally // The types and variables used locally
//typedef int bool; //typedef int bool;
typedef unsigned int uint; typedef unsigned int uint;
#define SVP(S) ((S) ? S : "<null>") //#define SVP(S) ((S) ? S : "<null>")
#define _strlwr(P) strlwr(P) //OB: changed this line #define _strlwr(P) strlwr(P) //OB: changed this line
#define MAX_PATHNAME_LEN 256 #define MAX_PATHNAME_LEN 256
#define N_CACHED_PROFILES 10 #define N_CACHED_PROFILES 10
...@@ -61,8 +61,8 @@ void htrc(char const *fmt, ...) ...@@ -61,8 +61,8 @@ void htrc(char const *fmt, ...)
} /* end of htrc */ } /* end of htrc */
#else // !TEST_MODULE #else // !TEST_MODULE
// Normal included functions // Normal included functions
extern int trace; //extern int trace;
void htrc(char const *fmt, ...); //void htrc(char const *fmt, ...);
#endif // !TEST MODULE #endif // !TEST MODULE
...@@ -112,10 +112,11 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL}; ...@@ -112,10 +112,11 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL};
//static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT("PROFILE_CritSect"); //static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT("PROFILE_CritSect");
static const char hex[16] = "0123456789ABCDEF"; static const char hex[17] = "0123456789ABCDEF";
BOOL WritePrivateProfileString(LPCSTR section, LPCSTR entry, BOOL WritePrivateProfileString(LPCSTR section, LPCSTR entry,
LPCSTR string, LPCSTR filename ); LPCSTR string, LPCSTR filename);
/*********************************************************************** /***********************************************************************
* PROFILE_CopyEntry * PROFILE_CopyEntry
* *
...@@ -254,7 +255,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) ...@@ -254,7 +255,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file )
PROFILESECTION* *next_section; PROFILESECTION* *next_section;
PROFILEKEY *key, *prev_key, **next_key; PROFILEKEY *key, *prev_key, **next_key;
first_section = malloc(sizeof(*section)); first_section = (PROFILESECTION*)malloc(sizeof(*section));
if (first_section == NULL) if (first_section == NULL)
return NULL; return NULL;
...@@ -281,7 +282,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) ...@@ -281,7 +282,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file )
*p2 = '\0'; *p2 = '\0';
p++; p++;
if (!(section = malloc(sizeof(*section) + strlen(p)))) if (!(section = (PROFILESECTION*)malloc(sizeof(*section) + strlen(p))))
break; break;
strcpy(section->name, p); strcpy(section->name, p);
...@@ -319,13 +320,13 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) ...@@ -319,13 +320,13 @@ static PROFILESECTION *PROFILE_Load( FILE *file )
} // endif p2 } // endif p2
if (*p || !prev_key || *prev_key->name) { if (*p || !prev_key || *prev_key->name) {
if (!(key = malloc(sizeof(*key) + strlen(p)))) if (!(key = (PROFILEKEY*)malloc(sizeof(*key) + strlen(p))))
break; break;
strcpy(key->name, p); strcpy(key->name, p);
if (p2) { if (p2) {
key->value = malloc(strlen(p2)+1); key->value = (char*)malloc(strlen(p2)+1);
strcpy(key->value, p2); strcpy(key->value, p2);
} else } else
key->value = NULL; key->value = NULL;
...@@ -452,7 +453,7 @@ static BOOL PROFILE_Open(LPCSTR filename) ...@@ -452,7 +453,7 @@ static BOOL PROFILE_Open(LPCSTR filename)
/* First time around */ /* First time around */
if (!CurProfile) if (!CurProfile)
for (i = 0; i < N_CACHED_PROFILES; i++) { for (i = 0; i < N_CACHED_PROFILES; i++) {
MRUProfile[i] = malloc(sizeof(PROFILE)); MRUProfile[i] = (PROFILE*)malloc(sizeof(PROFILE));
if (MRUProfile[i] == NULL) if (MRUProfile[i] == NULL)
break; break;
...@@ -520,7 +521,7 @@ static BOOL PROFILE_Open(LPCSTR filename) ...@@ -520,7 +521,7 @@ static BOOL PROFILE_Open(LPCSTR filename)
// strcpy(newdos_name, filename); // strcpy(newdos_name, filename);
// CurProfile->dos_name = newdos_name; // CurProfile->dos_name = newdos_name;
CurProfile->filename = malloc(strlen(filename) + 1); CurProfile->filename = (char*)malloc(strlen(filename) + 1);
strcpy(CurProfile->filename, filename); strcpy(CurProfile->filename, filename);
/* Try to open the profile file, first in $HOME/.wine */ /* Try to open the profile file, first in $HOME/.wine */
...@@ -783,7 +784,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section, ...@@ -783,7 +784,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section,
if (!create) if (!create)
return NULL; return NULL;
if (!(*key = malloc(sizeof(PROFILEKEY) + strlen(key_name)))) if (!(*key = (PROFILEKEY*)malloc(sizeof(PROFILEKEY) + strlen(key_name))))
return NULL; return NULL;
strcpy((*key)->name, key_name); strcpy((*key)->name, key_name);
...@@ -798,7 +799,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section, ...@@ -798,7 +799,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section,
if (!create) if (!create)
return NULL; return NULL;
*section = malloc(sizeof(PROFILESECTION) + strlen(section_name)); *section = (PROFILESECTION*)malloc(sizeof(PROFILESECTION) + strlen(section_name));
if (*section == NULL) if (*section == NULL)
return NULL; return NULL;
...@@ -806,7 +807,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section, ...@@ -806,7 +807,7 @@ static PROFILEKEY *PROFILE_Find(PROFILESECTION* *section,
strcpy((*section)->name, section_name); strcpy((*section)->name, section_name);
(*section)->next = NULL; (*section)->next = NULL;
if (!((*section)->key = malloc(sizeof(PROFILEKEY) + strlen(key_name)))) { if (!((*section)->key = (tagPROFILEKEY*)malloc(sizeof(PROFILEKEY) + strlen(key_name)))) {
free(*section); free(*section);
return NULL; return NULL;
} // endif malloc } // endif malloc
...@@ -1052,7 +1053,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name, ...@@ -1052,7 +1053,7 @@ static BOOL PROFILE_SetString(LPCSTR section_name, LPCSTR key_name,
} else if (trace > 1) } else if (trace > 1)
htrc(" creating key\n" ); htrc(" creating key\n" );
key->value = malloc(strlen(value) + 1); key->value = (char*)malloc(strlen(value) + 1);
strcpy(key->value, value); strcpy(key->value, value);
CurProfile->changed = TRUE; CurProfile->changed = TRUE;
} // endelse } // endelse
...@@ -1125,7 +1126,7 @@ static int PROFILE_GetPrivateProfileString(LPCSTR section, LPCSTR entry, ...@@ -1125,7 +1126,7 @@ static int PROFILE_GetPrivateProfileString(LPCSTR section, LPCSTR entry,
if (*p == ' ') { /* ouch, contained trailing ' ' */ if (*p == ' ') { /* ouch, contained trailing ' ' */
int len = p - (LPSTR)def_val; int len = p - (LPSTR)def_val;
pDefVal = malloc(len + 1); pDefVal = (LPSTR)malloc(len + 1);
strncpy(pDefVal, def_val, len); strncpy(pDefVal, def_val, len);
pDefVal[len] = '\0'; pDefVal[len] = '\0';
} // endif *p } // endif *p
...@@ -1277,7 +1278,7 @@ BOOL WritePrivateProfileSection(LPCSTR section, ...@@ -1277,7 +1278,7 @@ BOOL WritePrivateProfileSection(LPCSTR section,
ret = TRUE; ret = TRUE;
while (*string) { while (*string) {
LPSTR buf = malloc(strlen(string) + 1); LPSTR buf = (LPSTR)malloc(strlen(string) + 1);
strcpy(buf, string); strcpy(buf, string);
if ((p = strchr(buf, '='))) { if ((p = strchr(buf, '='))) {
......
...@@ -1507,23 +1507,16 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n, ...@@ -1507,23 +1507,16 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
ml += g->More; ml += g->More;
if (ml > g->Sarea_Size) { if (ml > g->Sarea_Size) {
#if !defined(DEVELOPMENT) FreeSarea(g);
if (trace)
#endif
htrc("Freeing Sarea at %p size=%d\n", g->Sarea, g->Sarea_Size);
free(g->Sarea);
if (!(g->Sarea = PlugAllocMem(g, ml))) { if (AllocSarea(g, ml)) {
char errmsg[MAX_STR]; char errmsg[MAX_STR];
snprintf(errmsg, sizeof(errmsg)-1, MSG(WORK_AREA), g->Message); snprintf(errmsg, sizeof(errmsg)-1, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
g->Sarea_Size = 0;
return true; return true;
} // endif Alloc } // endif SareaAlloc
g->Sarea_Size = ml;
g->Createas = 0; g->Createas = 0;
g->Xchk = NULL; g->Xchk = NULL;
initid->max_length = rl; initid->max_length = rl;
......
...@@ -334,7 +334,7 @@ PDBUSER PlgMakeUser(PGLOBAL g) ...@@ -334,7 +334,7 @@ PDBUSER PlgMakeUser(PGLOBAL g)
{ {
PDBUSER dbuserp; PDBUSER dbuserp;
if (!(dbuserp = (PDBUSER)PlugAllocMem(g, (uint)sizeof(DBUSERBLK)))) { if (!(dbuserp = (PDBUSER)malloc(sizeof(DBUSERBLK)))) {
sprintf(g->Message, MSG(MALLOC_ERROR), "PlgMakeUser"); sprintf(g->Message, MSG(MALLOC_ERROR), "PlgMakeUser");
return NULL; return NULL;
} // endif dbuserp } // endif dbuserp
......
...@@ -138,7 +138,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) ...@@ -138,7 +138,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
if (trace > 1) if (trace > 1)
htrc("PlugInit: Language='%s'\n", htrc("PlugInit: Language='%s'\n",
((!Language) ? "Null" : (char*)Language)); ((!Language) ? "Null" : (char*)Language));
try { try {
g = new GLOBAL; g = new GLOBAL;
...@@ -160,13 +160,11 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) ...@@ -160,13 +160,11 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
/*******************************************************************/ /*******************************************************************/
/* Allocate the main work segment. */ /* Allocate the main work segment. */
/*******************************************************************/ /*******************************************************************/
if (worksize && !(g->Sarea = PlugAllocMem(g, worksize))) { if (worksize && AllocSarea(g, worksize)) {
char errmsg[MAX_STR]; char errmsg[MAX_STR];
snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message); snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
g->Sarea_Size = 0; } // endif Sarea
} else
g->Sarea_Size = worksize;
g->jump_level = -1; /* New setting to allow recursive call of Plug */ g->jump_level = -1; /* New setting to allow recursive call of Plug */
return(g); return(g);
...@@ -183,15 +181,7 @@ int PlugExit(PGLOBAL g) ...@@ -183,15 +181,7 @@ int PlugExit(PGLOBAL g)
if (dup) if (dup)
free(dup); free(dup);
if (g->Sarea) { FreeSarea(g);
#if !defined(DEVELOPMENT)
if (trace)
#endif
htrc("Freeing Sarea at %p size=%d\n", g->Sarea, g->Sarea_Size);
free(g->Sarea);
} // endif Sarea
delete g; delete g;
} // endif g } // endif g
...@@ -459,30 +449,65 @@ short GetLineLength(PGLOBAL g) ...@@ -459,30 +449,65 @@ short GetLineLength(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Program for memory allocation of work and language areas. */ /* Program for memory allocation of work and language areas. */
/***********************************************************************/ /***********************************************************************/
void *PlugAllocMem(PGLOBAL g, uint size) bool AllocSarea(PGLOBAL g, uint size)
{ {
void *areap; /* Pointer to allocated area */
/*********************************************************************/ /*********************************************************************/
/* This is the allocation routine for the WIN32/UNIX/AIX version. */ /* This is the allocation routine for the WIN32/UNIX/AIX version. */
/*********************************************************************/ /*********************************************************************/
if (!(areap = malloc(size))) #if defined(__WIN__)
sprintf(g->Message, MSG(MALLOC_ERROR), "malloc"); if (size >= 1048576) // 1M
g->Sarea = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
else
#endif
g->Sarea = malloc(size);
if (!g->Sarea) {
sprintf(g->Message, MSG(MALLOC_ERROR), "malloc");
g->Sarea_Size = 0;
} else
g->Sarea_Size = size;
#if defined(DEVELOPMENT) #if defined(DEVELOPMENT)
if (true) { if (true) {
#else #else
if (trace) { if (trace) {
#endif #endif
if (areap) if (g->Sarea)
htrc("Memory of %u allocated at %p\n", size, areap); htrc("Work area of %u allocated at %p\n", size, g->Sarea);
else else
htrc("PlugAllocMem: %s\n", g->Message); htrc("SareaAlloc: %s\n", g->Message);
} // endif trace } // endif trace
return (areap); return (!g->Sarea);
} // end of PlugAllocMem } // end of AllocSarea
/***********************************************************************/
/* Program for memory freeing the work area. */
/***********************************************************************/
void FreeSarea(PGLOBAL g)
{
if (g->Sarea) {
#if defined(__WIN__)
if (g->Sarea_Size >= 1048576) // 1M
VirtualFree(g->Sarea, 0, MEM_RELEASE);
else
#endif
free(g->Sarea);
#if defined(DEVELOPMENT)
if (true)
#else
if (trace)
#endif
htrc("Freeing Sarea at %p size = %d\n", g->Sarea, g->Sarea_Size);
g->Sarea = NULL;
g->Sarea_Size = 0;
} // endif Sarea
return;
} // end of FreeSarea
/***********************************************************************/ /***********************************************************************/
/* Program for SubSet initialization of memory pools. */ /* Program for SubSet initialization of memory pools. */
......
...@@ -156,29 +156,20 @@ void user_connect::SetHandler(ha_connect *hc) ...@@ -156,29 +156,20 @@ void user_connect::SetHandler(ha_connect *hc)
bool user_connect::CheckCleanup(bool force) bool user_connect::CheckCleanup(bool force)
{ {
if (thdp->query_id > last_query_id || force) { if (thdp->query_id > last_query_id || force) {
uint worksize= GetWorkSize(); uint worksize= GetWorkSize(), size = g->Sarea_Size;
PlugCleanup(g, true); PlugCleanup(g, true);
if (g->Sarea_Size != worksize) { if (size != worksize) {
if (g->Sarea) { FreeSarea(g);
#if !defined(DEVELOPMENT)
if (trace)
#endif
htrc("CheckCleanup: Free Sarea at %p size=%d\n",
g->Sarea, g->Sarea_Size);
free(g->Sarea);
} // endif Size
// Check whether the work area could be allocated // Check whether the work area could be allocated
if (!(g->Sarea = PlugAllocMem(g, worksize))) { if (AllocSarea(g, worksize)) {
g->Sarea = PlugAllocMem(g, g->Sarea_Size); AllocSarea(g, size);
SetWorkSize(g->Sarea_Size); // Was too big SetWorkSize(g->Sarea_Size); // Was too big
} else } // endif sarea
g->Sarea_Size = worksize; // Ok
} // endif worksize } // endif worksize
PlugSubSet(g, g->Sarea, g->Sarea_Size); PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Xchk = NULL; g->Xchk = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment