[pywin32-checkins] pywin32/win32/src PyWinTypes.h, 1.64, 1.65 PyUnicode.cpp, 1.29, 1.30
OLD project page for the Python extensions for Windows
                
                Brought to you by:
                
                    mhammond
                    
                
            
            
        
        
        
    | 
      
      
      From: Mark H. <mha...@us...> - 2009-02-03 03:52:32
      
     | 
| Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13276/win32/src Modified Files: PyWinTypes.h PyUnicode.cpp Log Message: make PyWin_String_AsBstr a private function in the 1 place its used Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** PyWinTypes.h 3 Feb 2009 03:47:01 -0000 1.64 --- PyWinTypes.h 3 Feb 2009 03:52:29 -0000 1.65 *************** *** 241,247 **** PYWINTYPES_EXPORT PyObject *PyWinObject_FromBstr(const BSTR bstr, BOOL takeOwnership=FALSE); - // Convert a "char *" to a BSTR - free via ::SysFreeString() - PYWINTYPES_EXPORT BSTR PyWin_String_AsBstr(const char *str); - // Given a string or Unicode object, get WCHAR characters. PYWINTYPES_EXPORT BOOL PyWinObject_AsWCHAR(PyObject *stringObject, WCHAR **pResult, BOOL bNoneOK = FALSE, DWORD *pResultLen = NULL); --- 241,244 ---- Index: PyUnicode.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyUnicode.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** PyUnicode.cpp 3 Feb 2009 03:47:01 -0000 1.29 --- PyUnicode.cpp 3 Feb 2009 03:52:29 -0000 1.30 *************** *** 211,242 **** } - // Convert a "char *" to a BSTR - free via ::SysFreeString() - BSTR PyWin_String_AsBstr(const char *value) - { - if (value==NULL || *value=='\0') - return SysAllocStringLen(L"", 0); - /* use MultiByteToWideChar() as a "good" strlen() */ - /* NOTE: this will include the null-term in the length */ - int cchWideChar = MultiByteToWideChar(CP_ACP, 0, value, -1, NULL, 0); - - /* alloc a temporary conversion buffer, but dont use alloca, as super - large strings will blow our stack */ - LPWSTR wstr = (LPWSTR)malloc(cchWideChar * sizeof(WCHAR)); - if (wstr==NULL) { - PyErr_SetString(PyExc_MemoryError, "Not enough memory to allocate wide string buffer."); - return NULL; - } - - /* convert the input into the temporary buffer */ - MultiByteToWideChar(CP_ACP, 0, value, -1, wstr, cchWideChar); - - /* don't place the null-term into the BSTR */ - BSTR ret = SysAllocStringLen(wstr, cchWideChar - 1); - if (ret==NULL) - PyErr_SetString(PyExc_MemoryError, "allocating BSTR"); - free(wstr); - return ret; - } - // Size info is available (eg, a fn returns a string and also fills in a size variable) PyObject *PyWinObject_FromOLECHAR(const OLECHAR * str, int numChars) --- 211,214 ---- |