|
If you are using the same file object to read the file again, you need to seek the file pointer to beginning of file(BOF), before you read. This is so because you have read to End of File, and when you read again, it tries to read from current position of file pointer. You need to reset the current position to BOF.
I dont know what language are u using but it would be something like
file.Seek(0);
or
filestream.SeekBegin();
or something similar.
Regards,
Its never over !
|
|
|
|
|
shaibee wrote: If you are using the same file object to read the file again, you need to seek the file pointer to beginning of file(BOF), before you read.
The OP said the file was closed before attempting to open and read from it again.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
If you are reading something other than a text file (say, mp3 or mpeg), there can be multiple EOF in the same file. So it is a better idea to first calculate the size of the file and then read byte by byte.
Shibu
|
|
|
|
|
Use a seek function. If you opened with fopen(...) you use
fseek(F,0,SEEK_SET) to rewind it to the beginning.
Bram van Kampen
|
|
|
|
|
hi, all
code is,
----------------------------
CDialog * dlg;
while(TRUE)
{
dlg = new MyDialog;
dlg->Create(IDD_DIALOG, this);
Sleep(500);
dlg->DestroyWindow();
Sleep(500);
}
----------------------------
MyDialog is CDialog subcalssing,
MyDialog virtual method override PostNcDestroy()
void MyDialog::PostNcDestroy()
{
delete this;
CDialog::PostNcDestroy();
}
----------------
this code do not always memory leak.
but some time increase using memory. for 4kb... and not decrease using memory
What is problem??
|
|
|
|
|
is there some memory allocated in the constructor of the dialog, and not released in the destructor ?
also, how are you mesuring that memory ?
|
|
|
|
|
gamja wrote:
void MyDialog::PostNcDestroy()
{
delete this;
CDialog::PostNcDestroy();
}
You are calling a member function of your object *after* deleting it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If you believe you have memory leaks by looking at the Task Manager, you cannot trust the TM to tell you much about memory usage.
The code you've posted is fine, and doesn't leak memory. The Task Manager reports the amount of memory allocated to your process (the working set). When you initially release memory (no longer need it) the task manager does not immediately return that memory to available space - it holds on to it for a while.
You can probably see this if you display your dialog and then close it (you'll see that 4KB in the Task Manager). Next, minimize your application window and watch the task manager, then restore your window.
Hope that helps.
BTW - your PostNCDestroy is fine.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
gamja wrote: this code do not always memory leak.
but some time increase using memory. for 4kb... and not decrease using memory
How are you verifying this?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
verifying is simple.
Sleep time set short..
another example.
1. make project dialog base project.
2. dlg class, add subclass CDialog
3. dlg class, add member variable CDialog * m_dlg
4. dlg class set timer(Elapse 100ms, if possable more short!), and timer method define
5.
void Ctest1Dlg::OnTimer(UINT_PTR nIDEvent)
{
m_dlg = new MyDialog;
m_dlg->Create(IDD_MYDIALOG, this);
m_dlg->DestroyWindow();
delete m_dlg;
CDialog::OnTimer(nIDEvent);
}
5. build, and debug.
6. look task manager..
-----------------------------------
this project, fastest dialog new, and delete...
|
|
|
|
|
Hi All,
I am using Qt 4 integrated with Visual C++ 2005. In my project, i have some functions, that are called are called frequently. so i want to create a dll of those required functions and call them so that compiling time become less. Can you give some link related to this or any ideas?
With Regards,
Sangeetha.
|
|
|
|
|
|
Hi,
I have gone through it.. but its different in Visual C++ 2005. Please guide in that.
With Regards,
Sangeetha.
|
|
|
|
|
what do you find to be different ?
|
|
|
|
|
Hi,
In command line i could not delete the \D <proj_name> as they asked to do so in Step 3 in the link you referred.
With Regards,
Sangeetha.
|
|
|
|
|
this is done in the project settings for the compiler/linker...
right click on your project for its settings, and search for the parameter which is equivalent of the /D switch...
|
|
|
|
|
Yeah in the Project -> properties -> ConfigurationProperties -> C/C++ -> Command Line i tried.. But its not editable. Can u check in yours..?
With Regards,
Sangeetha.
|
|
|
|
|
Sangeetha_J wrote: Yeah in the Project -> properties -> ConfigurationProperties -> C/C++ -> Command Line i tried.. But its not editable
yeah, that's a summary of what's configured, and passed to the compiler at compile time.
and the settings you find in the property page are configured earlier in the dialog.
please use your brain (and your doc !)
|
|
|
|
|
If you want to exclude some functions in a DLL just hava a look at some articles on codeproject.com that describe how to develop a library.
|
|
|
|
|
Any info example or link with tutorial is welcome i searched google and didnt find nothing good.
I want to patch the call of the function so not do modify the original bytes of the function. I dunno if patching is same as redirection buth searched info for bouth didnt find anything. I want to redirect / patch a dll function return address to my addres ok thnx .
|
|
|
|
|
I don't really get what you're trying to do.
why don't you just get the original function's result, and add your calculation on its result then ?
|
|
|
|
|
Can ya do a example for me
|
|
|
|
|
nah1337 wrote: Can ya do a example for me
you're kidding, right ?
|
|
|
|
|
No im not see this
I want to redirect/ patch a call of the 10003DD7 function its addres is 0x0003DD7 and calls vsnprintf what addres is 0x0076533
int sub_10003DD7(char *Dest, size_t Count, char *Format, ...)
{
va_list va; // [sp+18h] [bp+10h]@1
int result; // eax@1
size_t v5; // esi@1
char *v6; // edi@1
va_start(va, Format);
v5 = Count;
v6 = Dest;
result = _vsnprintf(Dest, Count, Format, va);
v6[v5 - 1] = 0;
return result;
}
|
|
|
|
|
I think your best bet is to look up Matt Pietreck's various books and articles. He does that soort of thing on a regular basis.
Bram van Kampen
|
|
|
|