-
August 22nd, 2003, 04:07 AM
#16
Originally posted by souldog
I think the point of Mick's post is it is very unlikely that the CString
is really 2.1G so something else must be going on.
And here I thought that was obvious
-
August 22nd, 2003, 04:13 AM
#17
How do you create your string??
You may try:
Code:
CString str( _T('A'), INT_MAX-1 );
Good luck!
However:
2,147,352,576 == unreserved virtual memory (accessible by a process (NT)).
2,147,483,646 == INT_MAX - 1
Also I think, we are on a wrong path.
wangnanjing, would you, please, clarify your problem?
-
August 22nd, 2003, 04:21 AM
#18
Originally posted by irona20
How do you create your string??
If it is something like this:
CString str = "very huge string";
you can do the following:
CString str = "string shorter";
str += "the rest of the string";
I don't know how that would help if the length is really exceeded.
In fact this seems interesting. Consider this code for CString
PHP Code:
// NOTE: "operator+" is done as friend functions for simplicity
// There are three variants:
// CString + CString
// and for ? = TCHAR, LPCTSTR
// CString + ?
// ? + CString
void CString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
int nSrc2Len, LPCTSTR lpszSrc2Data)
{
// -- master concatenation routine
// Concatenate two sources
// -- assume that 'this' is a new CString object
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
memcpy(m_pchData, lpszSrc1Data, nSrc1Len*sizeof(TCHAR));
memcpy(m_pchData+nSrc1Len, lpszSrc2Data, nSrc2Len*sizeof(TCHAR));
}
}
CString AFXAPI operator+(const CString& string1, const CString& string2)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
string2.GetData()->nDataLength, string2.m_pchData);
return s;
}
So what happens if the sum of the lengths exceeds the size of int?
here
PHP Code:
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
Am I seeing things
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
August 22nd, 2003, 04:26 AM
#19
Originally posted by souldog
I don't know how that would help if the length is really exceeded.
In fact this seems interesting. Consider this code for CString
PHP Code:
// NOTE: "operator+" is done as friend functions for simplicity
// There are three variants:
// CString + CString
// and for ? = TCHAR, LPCTSTR
// CString + ?
// ? + CString
void CString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
int nSrc2Len, LPCTSTR lpszSrc2Data)
{
// -- master concatenation routine
// Concatenate two sources
// -- assume that 'this' is a new CString object
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
memcpy(m_pchData, lpszSrc1Data, nSrc1Len*sizeof(TCHAR));
memcpy(m_pchData+nSrc1Len, lpszSrc2Data, nSrc2Len*sizeof(TCHAR));
}
}
CString AFXAPI operator+(const CString& string1, const CString& string2)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
string2.GetData()->nDataLength, string2.m_pchData);
return s;
}
So what happens if the sum of the lengths exceeds the size of int?
here
PHP Code:
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
Am I seeing things
Speculation I'd like to see what is going on first....
thank you very little
-
August 22nd, 2003, 04:28 AM
#20
Well, I don't think that the SQL statment are so huge.
I had this problem once:
Code:
CString strAux = "SELECT DISTINCT \
GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
GenInfArbolesCF.nGIAR_COMPORT, \
GenInfArbolesCF.nGIAR_TIPOEJE, \
GenInfArbolesCF.nGIAR_PROFUN, \
GenInfArbolesCF.sGIAR_NODO, \
MasterTreesStructure.NodeCode, \
MasterTrees.TreeNumberOfLevels,\
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder \
FROM GenInfInforme INNER JOIN \
GenInfInformeDetalles ON \
(GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
INNER JOIN \
GenInfArbolesCF ON \
(GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
AND \
GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
AND \
GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
AND \
GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
INNER JOIN \
MasterTrees ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
INNER JOIN \
MasterTreesStructure ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
GenInfInforme.sINFO_USUARIO = '%s') AND \
((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
((MasterTrees.TreeNumberOfLevels - 1) \
> MasterTreesStructure.NodeLevel))) AND \
((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
- 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
ORDER BY GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder";
I have to split my string because I get an error in runtime. So, maybe it is the same error.
I am Miss Maiden... Miss Iron Maiden :-D
-
August 22nd, 2003, 04:31 AM
#21
Originally posted by Mick_2002
Speculation I'd like to see what is going on first....
thank you very little
I didn't mean that to be related to this guys problem. I mean is that a bug in CString
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
August 22nd, 2003, 04:34 AM
#22
Originally posted by irona20
Well, I don't think that the SQL statment are so huge.
I had this problem once:
Code:
CString strAux = "SELECT DISTINCT \
GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
GenInfArbolesCF.nGIAR_COMPORT, \
GenInfArbolesCF.nGIAR_TIPOEJE, \
GenInfArbolesCF.nGIAR_PROFUN, \
GenInfArbolesCF.sGIAR_NODO, \
MasterTreesStructure.NodeCode, \
MasterTrees.TreeNumberOfLevels,\
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder \
FROM GenInfInforme INNER JOIN \
GenInfInformeDetalles ON \
(GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
INNER JOIN \
GenInfArbolesCF ON \
(GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
AND \
GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
AND \
GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
AND \
GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
INNER JOIN \
MasterTrees ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
INNER JOIN \
MasterTreesStructure ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
GenInfInforme.sINFO_USUARIO = '%s') AND \
((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
((MasterTrees.TreeNumberOfLevels - 1) \
> MasterTreesStructure.NodeLevel))) AND \
((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
- 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
ORDER BY GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder";
I have to split my string because I get an error in runtime. So, maybe it is the same error.
What was the runtime error? The char looks proper to me
-
August 22nd, 2003, 04:36 AM
#23
Originally posted by souldog
I didn't mean that to be related to this guys problem. I mean is that a bug in CString
I didn't look...should I look? Given the number of bugs in MFC I do not doubt it
-
August 22nd, 2003, 04:40 AM
#24
Originally posted by Mick_2002
What was the runtime error? The char looks proper to me
I don't renember, it was three years ago I only renember I had to split my string.
I am Miss Maiden... Miss Iron Maiden :-D
-
August 22nd, 2003, 04:40 AM
#25
For wangnanjing
If your problem is really an SQL statement, something like "SELECT blabla,... FROM...",
If you can zip and attach it here, then there is no problem. For sure, somebody will help you.
I have a supposition. Somehow your "SQL" is a long binary field in a recordset,
and you had some problems trying to put it in a CString ???
-
August 22nd, 2003, 04:45 AM
#26
Originally posted by irona20
I don't renember, it was three years ago I only renember I had to split my string.
Heh it's ok Irona...given the number of responses, it will be three years before the original poster responds
-
August 22nd, 2003, 04:51 AM
#27
Originally posted by Mick_2002
I didn't look...should I look? Given the number of bugs in MFC I do not doubt it
Do you know any software stuff without bugs?
Yes? That means it does nothing.
-
August 22nd, 2003, 04:54 AM
#28
Originally posted by ovidiucucu
Do you know any software stuff without bugs?
Yes? That means it does nothing.
Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....
EDIT: does it piss me off to no end that you have that attitude? yes it does.
-
August 22nd, 2003, 05:14 AM
#29
Originally posted by Mick_2002
Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....
Sorry man, you must throw it away!
Or it's insufficient tested, or nobody use it except you.
Keep in mind: nothing is perfect.
Originally posted by Mick_2002
EDIT: does it piss me off to no end that you have that attitude? yes it does.
I hope no offense, Just
-
August 22nd, 2003, 05:24 AM
#30
Originally posted by ovidiucucu
Sorry man, you must throw it away!
Or it's insufficient tested, or nobody use it except you.
Keep in mind: nothing is perfect.
Wow...geez, I've never coded for the big boys Why don't you try your attitude when coding for medical devices? Hmm? Maybe your NIBP isn't what your NIBP is? hmm? Maybe somebody makes a descision based on your cardiac calcs? Maybe then your dead
Stupidity is no offense, it's called darwinism
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|