--- sql/odbc/parser3odbc.C 2002/12/09 12:33:28 1.12 +++ sql/odbc/parser3odbc.C 2003/03/26 14:09:06 1.13.6.1 @@ -1,11 +1,11 @@ /** @file Parser ODBC driver. - Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char *RCSId="$Id: parser3odbc.C,v 1.12 2002/12/09 12:33:28 paf Exp $"; +static const char *RCSId="$Id: parser3odbc.C,v 1.13.6.1 2003/03/26 14:09:06 paf Exp $"; #ifndef _MSC_VER # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)] @@ -126,20 +126,19 @@ public: return true; } - unsigned int quote( - SQL_Driver_services&, void *connection, - char *to, const char *from, unsigned int length) { - if(to) { // store mode - unsigned int result=length; - while(length--) { - if(*from=='\'') { // ' -> '' - *to++='\''; result++; - } - *to++=*from++; + const char* quote( + SQL_Driver_services& services, void *connection, + const char *from, unsigned int length) { + char *result=(char*)services.malloc_atomic(length*2+1); + char *to=result; + while(length--) { + if(*from=='\'') { // ' -> '' + *to++='\''; result++; } - return result; - } else // estimate mode - return length*2; + *to++=*from++; + } + *to=0; + return result; } void query( SQL_Driver_services& services, void *connection, @@ -203,7 +202,7 @@ public: size_t size=fieldinfo.m_strName.GetLength(); void *ptr=0; if(size) { - ptr=services.malloc(size); + ptr=services.malloc_atomic(size); memcpy(ptr, (char *)LPCTSTR(fieldinfo.m_strName), size); } CHECK(handlers.add_column(sql_error, ptr, size)); @@ -272,7 +271,7 @@ public: { char local_buf[MAX_NUMBER]; size=snprintf(local_buf, MAX_NUMBER, "%ld", v.m_lVal); - ptr=services.malloc(size); + ptr=services.malloc_atomic(size); memcpy(ptr, local_buf, size); break; }*/ @@ -284,7 +283,7 @@ public: case DBVT_BINARY: { if(size=v.m_pbinary->m_dwDataLength) { - ptr=services.malloc(size); + ptr=services.malloc_atomic(size); memcpy(ptr, ::GlobalLock(v.m_pbinary->m_hData), size); ::GlobalUnlock(v.m_pbinary->m_hData); } else @@ -303,7 +302,7 @@ public: v.m_pdate->minute, v.m_pdate->second, v.m_pdate->fraction); - ptr=services.malloc(size); + ptr=services.malloc_atomic(size); memcpy(ptr, local_buf, size); break; } @@ -322,7 +321,7 @@ public: } else { const char *cstr=LPCTSTR(s); size=strlen(cstr); //string.GetLength() works wrong with non-string types: - ptr=services.malloc(size); + ptr=services.malloc_atomic(size); memcpy(ptr, cstr, size); } }