|
long **iLut3Ddata;
iLut3Ddata =new long *[27];
for(i =0; i<=27;i++)
{
iLut3Ddata[i] = new long[10];
}
for(i=0;i<ldatasize;i++){
for(iodd="9,iEven=8;iOdd">0&&iEven>-1;iOdd-=2,iEven-=2,ii++){
LutData3D[ii] = (unsigned char)iLut3Ddata[i][iEven]; //& iLut3Ddata[i][iOdd];
LutData3D[ii] = LutData3D[ii]<<4|(unsigned char)iLut3Ddata[i][iOdd];
}
for(int ix=0;ix
|
|
|
|
|
icemelt(newbie) wrote: iLut3Ddata =new long *[27];
for(i =0; i<=27;i++)
Immediate problem I'm seeing here is,
it should be,
iLut3Ddata =new long *[27];
for(i =0; i<27;i++)
{
iLut3Ddata[i] = new long[10];
}
In C++ there are 0 based array index.
Here you are writing out of bounds of allocated memory. Hence , it is causing problem , while deleting memory.
|
|
|
|
|
for(int ix=0;ix<ldatasize;ix++){
delete="" []="" ilut3ddata[ix];
="" }
="" <b="">iLut3Ddata=NULL;
delete [] iLut3Ddata;
still the same error occurs but when i add NULL on the array
it doesnt generate error anymore but it detected memory leaks
thanks
|
|
|
|
|
Can you check the Ignore HTML tags... checkbox so we can read your code?
icemelt(newbie) wrote: but it detected memory leaks
Assuming you've corrected the for() statement as shown in Prasad_som's example...
You're allocating 27 blocks of memory on the heap. Are you deleting them ever?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
You code is not readable at all,
From your original post, I'm guessing your code, how its should look like,
long **iLut3Ddata ;
iLut3Ddata =new long *[27];
for(i =0; i< 27;i++)
{
iLut3Ddata[i] = new long[10];
}
for(int ix = 0; ix < 27 ; ix++)
{
delete [] iLut3Ddata[ix] ;
iLut3Ddata[ix] = NULL ;
}
delete [] iLut3Ddata;
iLut3Ddata = NULL;
|
|
|
|
|
thanks for the code im really still an infant to c++
I was a visual basic programmer back then,
anyways thanks,
|
|
|
|
|
icemelt(newbie) wrote: I was a visual basic programmer back then
I understood it, when you used index up to number of elements in array.
|
|
|
|
|
I need to audit an exe file to ensure that only Administrators have write access. Non-Administrators can have execute access. This is a read-only audit; I will not alter the existing security of a file.
I have tried to search the MSDN and the CodeProject articles. If someone knows what keywords would work for finding answers then that might be all I need.
I don't need a complete sample; just a general direction I hope is enough.
I know about DACLs and SIDs and authorities and RIDs and ACLs and ACEs. I suspect that I need to use the AccessCheck function, but it is certainly complicated. If someone can verify that AccessCheck will do what I need to do then that will help.
|
|
|
|
|
Hello,
i have a dialog based application.
in this dialog i startet a modeless-child-dialog with createdialog.
the child dialog has the properties border = none and style = child.
if the child dialog is closed, i want to call the parent dialog. i can call public functions of the parent dialog, but if i try to change some public variables (i.e. the menu) of the parent dialog, i get an access violation. how cann i invoke the parent, that the child dialog is closed???
if i try to make a modal dialog of the child dialog, then the app freezes.
thanks
-- modified at 18:14 Friday 9th March, 2007
|
|
|
|
|
Can you show your code that it has problem
|
|
|
|
|
Hello,
i found my fault. I simply give the child-dialog a reference to the parent dialog (constructor) and then i can call methods of the parent without getting an access violation.
thanks anyway.
|
|
|
|
|
All I can think of off hand is:
1) Make sure both places refer to the SAME variable. For example, I occasionally make the mistake
of copy/pasting a member variable declaration with its type into code somewhere so it ends up
being a local variable where I copied it, instead of referring to the member variable
2) It's possible to overwrite an array (string, etc.) member that is positioned before the bool
member variable. There's no exception because it's still in valid memory but it trashes the bool.
I've done that one before too .
It may be helpful to put a variable-changed breakpoint on the bool variable. Then your program
will break when the bool is changed and you can look at the stack trace to see who the culprit is.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hello Mark,
I'm sure that the variable is the same, so I'll check the second scenario, who knows...
Thank you for your feedback!
|
|
|
|
|
Sort of newbie question here. I've read in places that you should avoid returning large class objects (particulary the class String) or datastructures, and instead should call a function and send it back by reference. Like this (ExpressionData is a structure with 3 cstrings):
void CRatiosNewSearchStringDialog::GetExpressionData(SearchExpressionType & Expression)
{
Expression = ExpressionData;
}
as opposed to:
SearchExpressionType CRatiosNewSearchStringDialog::GetExpressionData()
{
return ExpressionData;
}
Where should I draw the line between a large and small piece of data i.e should I bother with all this for a single CString? When should I use return and when should I sent it back by reference? Advice?
|
|
|
|
|
I'm porting some code from gcc to VC++, and a macro I've used for years on gcc is giving me grief on VC++ (Visual Studio 2003).
#define swap16(x) \
({ \
unsigned __int16 __x = (x); \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0xff00) >> 8) )); \
})
int _tmain(int argc, _TCHAR* argv[])
{
printf("%d\n", swap16(1);
return 0;
}
This code snippet generates several syntax errors. Any suggestions on resolving this issue are most welcome.
-Josh
|
|
|
|
|
joswr1ght wrote: Any suggestions on resolving this issue are most welcome.
Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
led mike
|
|
|
|
|
led mike wrote: Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
Are you referring to the /P option? It writes the preprocessor output to a .i file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Are you referring to the /P option? It writes the preprocessor output to a .i file.
If it works I am, if not you are.
led mike
|
|
|
|
|
Hmmm....why not just do this...
#define swap16(x) \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0xff00) >> 8) ))
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I have a straightforward CPropertySheet with CPropertyPages. I need to reset the contents of page "A", depending on the settings on other pages, which means I need a way to catch when pages "open" and "close"
I can catch when a page "opens" by overriding OnChildActivate but I can't catch when a Page "closes". Any suggestions on a sane way to trap these events?
(Note, I know about OnInitDialog() for "open" or OnOk() for "close". Neither of these methods are guaranteed to be called when just bouncing back and forth between pages by clicking on tabs)
Thanks in advance.
|
|
|
|
|
On the pages themselves, you can override OnSetActive and OnKillActive and do whatever you need to do to the parent PropertySheet or other Property pages.
onwards and upwards...
|
|
|
|
|
hello,
I am building an application in VC 6wherein when the user clicks ona particular button, a query is fired to SQL SErver 2000 database and a report (crystal reports 8.5) is generated based on the data retrieved. I am having multiple clients which connect to the SQL server remotely. so while retrieving, i will need to specify the IP of the machine where the DB is stored.
I have heard of a function callled SetLogonInfo which allows a user to change the databse name on the fly. But when I add an Active X control to my app, the version of SetLogonInfo takes only 2 parameters...."void SetLogonInfo(short index, LPCTSTR lpszNewValue); ...instead of 4 which i have seen in most standard implementations. Could you please give me more details regarding this function and how do I connect remotely for crystal reports? What is the code that i need to include in this function?
Awating Your Reply
Thank You
|
|
|
|
|
|
I would like to use an initialization file to set some features of how my Visual C++ API will run. I would like to be able to set these from within the API to be used next time the application is started. Is there a "simple" solution?
|
|
|
|
|
You can use INI files, but I prefer by far using XML files, they are easy to use and also you can use the DTD files in order to check the correctness of everything.
You can also use the registry, but is far more complicated and then it is also more complicated to move the program from one PC to another one.
In order to use them you should check the articles here in CP, I'm sure that you can find lots of information on that.
Hope this helps.
|
|
|
|