|
peterchen wrote:
guard bytes,
Sir,If you don't Midn please tell me What is Guard bytes
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
No need for the Sir, Sir
malloc_dbg calls malloc, but requests a few more bytes. These bytes are filled with a predefined value. free_dbg then checks if these extra bytes still hold this value. If they did, you probably wrote beyond the allocated memory (The VC Runtime prints a diagnostic message to the debug output)
Typical implementations add 4 bytes at the end. In this case, using free instead of _free_dbg is often not a problem, but depending on the implementation, it might leak the guard bytes.
But if an implementation adds guard bytes *before* the memory provided to you (to detect underflows, which are less common), using free instead of -free_dbg is likely to corrupt the heap.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Yeah Right,
I understand _malloc_dbg and _free_dbg thanks.
About
peterchen wrote:
Sir
That a way to Show Respect to Elder.
Thanks Again Sir!!!
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi
Can someone tell me how to program an alt+tab replacement similar to the one microsoft uses in the powertoys?
Capturing Alt+Tab probably won't be the problem, but how to I replace the dialog in the center of the screen with my own?
See http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Here is an article that demonstrates XP Visual styles but also has examples of the code you are looking for...
ALT-TAB enhanced with XP styles[^]
Alex Korchemniy
|
|
|
|
|
That's great, thanks a lot!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks for the info. I suspected this was not possible but it would have been so handy.
Yarp
http://www.senosoft.com/
|
|
|
|
|
You can use the functions: _splitpath and _makepath or _fullpath.
Or their Generic-Text Routine Mappings: _tsplitpath, _tmakepath, _tfullpath.
In order to break the path apart and put it back together. Thats easier than trying to break it up youself. Of you cource you could just copy the module path into a temporary buffer, search for myAppName.exe and replace it, but that is not generic.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I'm trying to update a text file by overwritting a part of the text in the middle of the file. I'm using the fwrite function.
I manage to overwrite something unfortunately the new text overlaps the text of the contiguous line when it is longer than previous text.
For example:
My first line
Line to override
My next line
Gives:
My first line
Overriden line which is longer
ext line
I wonder if it is possible to insert longer than previous line text with fwrite and if so how to do, if not how to do
I don't have the code here but it is something like the folowing (assuming you are reading line 2 only):
<br />
fFile = fopen("myfile.txt", "r+");<br />
...<br />
fgets(pBuffer)) {<br />
ftell();<br />
fWrite("new text");<br />
fflush(fFile)<br />
...<br />
}<br />
fclose(fFile);<br />
Sorry for the code, if you want more I can post it later.
Yarp
http://www.senosoft.com/
|
|
|
|
|
No, you cant do that way, you have to read the whole file into a buffer, make the change in the buffer and then write to the file.
for safetly you write it to a temp file and if the write succeeds then rename it to the original file name ofcource delete the first one.
or if you are not too bother about data in the file and would like to take a change, then write it to the same file.
-prakash
|
|
|
|
|
hi folks,
First, just to let you know that I use g++ to compile the src containing following code segments. Now lets start the business.
This is a templated class method I got:
template<class T>
void
SynchList<T>::Apply(void (*func)(T))
{
lock->Acquire();
list->Apply(func);
lock->Release();
}
and this is the function pointed by the function pointer:
void
SimpleThread(Thread *tmpThread)
{
int num;
for(num = 0; num < 5; num++)
{
cout << "***thread " << tmpThread->GetId() << " looped " << num << " times" << endl;
kernel->currentThread->Yield();
}
}
I have "bathList" as a pointer to SynchList<Thread *>:
SynchList<Thread *> *bathList = new SyncList<Thread *>;
and this is how I implement it (@ line 494 of the src):
bathList->Apply((void) (SimpleThread)(Thread *));
but I get this error msg everytime I try to compile the code:
../threads/thread.cc:494: parse error before '*'
Any help would be greatly appreciated.
Thank you all,
James
|
|
|
|
|
Lucky you I just wrote at least a dozen template classes and template functions the take function pointers as arguments so this should help!
Your function pointer agument must match the actual function pointer that is passed (C++ is far more picky than C):
LONG (*Func)(A1,T*) != LONG (WINAPI *Func)(A1,T*)
void (*Func)(T) != void (_cdecl *Func)(T) // THIS PROBABLE THE PROBLEM
void (CDECL *Func(T*) == void (_cdecl *Func)(T*)
Here is a partial example of a templated function that takes a function pointer as an argument (Note the template take the function pointer argument not the function that is produced):
template<class T, class A1, LONG (WINAPI *Func)(A1,T*)>
T* my_Get1(A1 Arg1)
{
...
T* pData = new T;
nResult = Func(Arg1,&pData);
...
return pData;
}
void someFunc()
{
...
MYTYPE pT = my_Get1<MYTYPE,ARGTYPE,MyFunc>(Arg1);
...
delete pT;
}
Have fun!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
with all do respect,
I reckon the pointer argument I pass to the method matches to the actual function pointer argument.
Given the function signature is:
void
SynchList<T>::Apply(void (*func)(T))
and I implement it as:
bathList->Apply((void) (SimpleThread)(Thread *));
where bathList points to "SynchList<Thread *>" , "SimpleThread" is a funciton name, and "Thread *" is same as in "SynchList<Thread *>"
Is there anything else that I probably didn't notice causing the error ?
Your kindness is truly appreciated !
|
|
|
|
|
If you wrote the function like so:
void SimpleThread(Thread* pThread)
{
...
}
The try the following:
bathlist->Apply(SimpleThread); // The name SimpleThread is the pointer
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
thank you John,
bathList->Apply(SimpleThread) actually works !!
I did what I did to try to follow the signature and didn't even notice that the argument (Thread *) itself is illegal at all. I think template instantiation takes care of that by induction, and since "SimpleThread" is already a void function, so no need to re-cast (void) again ?
Am I heading the right direction ?
Thanks again.
James
|
|
|
|
|
Your welcome and yes.
void (*Func)() // is a user defined function pointer type named 'Func'
The only difference between it and a biult in type like 'double' is that it is user defined. If you can not pass 'double' as an argument, then you can not pass 'void (*Func)()' as an argument; besides it makes no since (once you realize it is a variable type and not a variable).
That was just some food for thought!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Does that mean you have tried
void<br />
SynchList::Apply(void (_cdecl *func)(T))
and it does not work!?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
No, did not need to, but I have now:
int foo(int n)
{
return n + 1;
}
int foo2(int (*Func)(int))
{
return Func(1);
}
int foo3()
{
return foo2(foo);
}
int foo4()
{
return foo2(int (__cdecl *foo)(int));
}
int WINAPI foo5()
{
return 1;
}
int foo6(int (*Func)())
{
return Func();
}
int foo7()
{
return foo6(foo5);
}
int foo8(int (WINAPI *Func)())
{
return Func();
}
int foo9()
{
return foo8(foo5);
}
Sorry about that, the compiler assumes __cdecl calling convension.
Got to go! Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
This is John again, visiting from customer sight.
Sorry misslead you a little bit:
// Errors: Argument is a TYPE not a function pointer
return foo2(int (__cdecl *foo)(int));
Example:
int fun1(int n) { return n+1; }
int fun2()
{
return func1(int);
}
|
|
|
|
|
caption font of dialog on XP is larger than font on other OS (i.e. win98).
caption text can be displayed properly on win98 but only part of text can be displayed on XP (too long).
can we change caption font for XP so it becomes the same as on win98?
thx
includeh10
|
|
|
|
|
if you want a 2k looks you can do it somewhere in display properties.
-prakash
|
|
|
|
|
I think
you can change Theames
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
just like in subject... i need some method for determining full path of application. what i want to achieve is to create ini file in the same folder as application but method which creates file requires full path.
thx in advance
|
|
|
|
|
Take a look at
GetModuleFileName()
Hope that helps
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Remember to strip-off the filename from the end of the string returned from GetModuleFileName()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|