|
Senks for everybody, it was very helpful.
|
|
|
|
|
Hi
I have created a network based video streaming application. Now i want to generate the documentation as well as the flow diagrams and uml diagrams for that project. Can someone suggest me a free nice tool which can do this??
Regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
saqib82 wrote: Now i want to generate the documentation
You can use doxygen[^] for that part. But of course you still have to write the documentation yourself (in the source files). But it generates nice html output files which are really great to document classes and functions.
|
|
|
|
|
I have a list (CList) of pointers. Some of them point to variables in the heap a some others not.
I've defined a destructor that frees the memory space, but the program crashes when I delete a pointer to a variable in the stack.
The question is, is there any way of detecting if a pointer points to a variable in the stack or in the heap??
CMyList::~CMyList()
{
POSITION pos = GetHeadPosition();
while (pos != NULL)
{
if (GetNext(pos) points to the heap)
delete GetAt(pos);
}
RemoveAll();
}
|
|
|
|
|
piul wrote: is there any way of detecting if a pointer points to a variable in the stack or in the heap??
I think its possible to find. Normally the stack size will be 1 MB, so a pointer to an object pointing to stack will have the value between the Stack top - 1MB to Stack top. All other pointer will be pointing to heap. You can get the stack top from the TIB as follows.
DWORD dwStackTop = 0;
__asm
{
mov EAX, FS:[4]
mov dwStackTop, eax
}
modified on Thursday, April 17, 2008 5:21 AM
|
|
|
|
|
piul wrote: I have a list (CList) of pointers. Some of them point to variables in the heap a some others not.
This is not an answer to your question but it looks that there's a little problem with how you designed your app. Why do you need to mix pointers from the heap with pointers from the stack in the same list ?
Which kind of objects does your list contain ? How do you insert new elements in the list ? Can you provide some code ?
|
|
|
|
|
In my application, in theory the list should be filled with pointers to the heap. I understand that it is not good practice to mix pointers. However, I am developing it at the moment and making it crash very often, as I am making tests and so on. I was just wondering if there is an easy way of detecting this, so I stop crashing the program and showing an error message instead.
That is, it's not that I want to mix pointers in the same list, but I want to make sure that I am not doing it by mistake and find out only when the program crashes.
|
|
|
|
|
piul wrote: That is, it's not that I want to mix pointers in the same list, but I want to make sure that I am not doing it by mistake and find out only when the program crashes.
Probably avoiding pointer mixing will be a good starting point to prevent crashes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
The problem you describe could also be seen as a design problem, not an implementation problem.
Instead of the list taking care of destruction (and therefore passing ownership sometimes but not always), let the list elements take care of destruction and clean up them selfs. You could populate the list with a smart pointer that knows what to do, i.e. boost shared pointer[^]. So when you remove one (or many) entries the destructor of the shared pointer will take care of clean up, e.g. call delete for elements created on the heap.
However, generally I would not mix heap and stack and rather create all elements dynamically. Just saves you a lot of trouble and ownership will be crystal clear.
/M
|
|
|
|
|
If I remember my history correctly, a certain bit is set on all dynamically allocated memory? I believe that dynamic allocation maps into your address space at a certain starting address, and you can see if you are above that address.
I am pretty certain that there is a bit that is set for all addresses used for heap allocations.
But as others have said, there is some other problem in how your list is designed or being used.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: I am pretty certain that there is a bit that is set for all addresses used for heap allocations.
I would like to know more about this bit settings. Can give some more explanation or give me some like that explains this...
Thanks
|
|
|
|
|
It's a strange question. But here's how it can be done:
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
bool IsOnStack(const void *pData)
{
DWORD StackBase;
DWORD StackLimit;
__asm
{
MOV EAX, DWORD PTR FS:[0x04]
MOV StackBase, EAX
MOV EAX, DWORD PTR FS:[0x08]
MOV StackLimit, EAX
}
DWORD Address = reinterpret_cast<DWORD>(pData);
return (Address >= StackLimit) && (Address < StackBase);
}
const char* PrintStack(const void *pData)
{
return IsOnStack(pData) ? ": Stack" : ": Not on Stack";
}
int main(int argc, char* argv[])
{
const char *pString1 = "String1";
cout << pString1 << PrintStack(pString1) << endl;
char String2[] = "String2";
cout << String2 << PrintStack(String2) << endl;
return 0;
}
Output is:
String1: Not on Stack
String2: Stack
Steve
|
|
|
|
|
Hello,
is there any possibility available to get the projectname during the compiletime? I need the projectname as string...
Best regards
Hansjörg
|
|
|
|
|
Can you more explain Im not sure you need to GetModuleBaseName or no?
|
|
|
|
|
1) Get the value of project name from the project property
if you are using VS2005,
vsproperty->c/c++->preprocessor->preprocessor definitions: PROJECT_NAME=$(ProjectName)
2) Now use the PROJECT_NAME Macro from above in your code,
#define STRINGIZE(_x) #_x
#define STRINGIZEVALUE(_x) STRINGIZE(_x)
char projectName[]= STRINGIZEVALUE(PROJECT_NAME);
|
|
|
|
|
Rajkumar R wrote: #define STRINGIZE(_x) #_x
#define STRINGIZEVALUE(_x) STRINGIZE(_x)
Clever.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hi friends
How to calculate system measurement like When i was ON my PC my application run automatically calculate system time how to do it ?please give your suggestion.
Thanks and Regards
Nisha.S
|
|
|
|
|
Your query is not too much clear to me. I think you want to display the time for which your application has been runnning. So, when your application starts do a GetSystemTime() and store the values in some variable. Later you can again do a GetSystemTime() and calculate the difference.
In essesnce you must state your problem more clearly if you expect to the point solution from CP members.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
k..currently i create one tool
i want to create "Total usage of System time"
1. When the user logging him/her PC at that time my application counting the
time(it means running hours)
2. Suppose When user shut down or log off at that time my application close
close the time finally it will return total no of calculating system
hours. This is my tool ...give the procedure how i can start that project
or send me some URLs please..
Regards
Nisha.S
|
|
|
|
|
To run as a user process you have to add its path in registry. Copy the following and make a file named setup.reg:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"AnyName"="C:\\Program Files\\YourAppFolder\\YourApp.exe"
and run it. Don't forget to edit to match your application.
To run as ser5vice look at this article:
http://www.codeproject.com/KB/system/xyntservice.aspx[^]
Now the second part - how to calculate time:
Its easy use GetSystemTime API
http://msdn2.microsoft.com/en-us/library/ms724390.aspx[^]
|
|
|
|
|
Are you needing to know how long the computer was up and running? I mean - the time elapsed between boot and shut down? In that case, GetSystemTime is not what you need. Google for Find windows uptime[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Do you need to GetProcessTimes ?
|
|
|
|
|
thanks 2 your replays..
yes hamid i need get process time calculation ....
By
Nisha.S
|
|
|
|
|
|
Im writing a registration database program in C++ that :
Allows the user to enter prompted information in a struct, the user then has the choice of performing the menu options such as adding a student, deleting, lookup a student, add course, etc. At any time the user should be able to view the existing student files.
How do save the student information to an Outfile that can be accessed.
Do I put outfile code in every function???
I'm lost. Can provide code if needed.
|
|
|
|