|
|
which can be used in any machine.
How do i do that?
Here![^]
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
Hello,
I am working for C project. The codebase exist since long time(more than 10 years).
We are using lots of structures with fixed array size. Like
struct tagMystruct
{
char name[256];
char disign[256];
.
.
}
Now new requirement came, I have to change fixed size arrays to dynamic arrays. I defined new array like
struct tagMystruct
{
char *name;
int nameLength;
char *disign;
int disgLength;
.
.
}
Is this correct approcach? In my existing code in lot many places we are using strcpy, strcat etc..
Now i have to check the buffer all the place before calling any function. It will take more time and regression? Can i know how can achive or any new ways?
Thanks and Regards,
Chandu
|
|
|
|
|
If the requirement is it must remain C code, then you have to do something like that you've exposed in your post.
However, if you can afford the C++ power then I strongly suggest to use STL's std::string instead of char * (at least toxcct will be happy ).
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.
|
|
|
|
|
As another wrote, think whether it can be a C++ project so, you can use classes. For instance you can use the std libs or the MFC (with CString). There are a lot of other classes here at CP.
Try to develop with structs, as
stringStruct
{
int l;
char *p;
}
If you cant use classes you should think about implementing often used operations in funktions.
SetString( stringStruct *p, "new string" )
{
//do stuff
}
Greetings from Germany
|
|
|
|
|
chanduabcchandu wrote:
struct tagMystruct
{
char *name;
int nameLength;
char *disign;
int disgLength;
...}
Yes, you can do that since you mention that it is a "C" project, hence no C++ code. If you can build the project in C++, you can then use string objects (MFC's CString , STL's std::string ) that will handle the memory allocations for you as well as supply methods for assignment, concatenation/appending, etc.
If you have to stick with the manually-managed buffers, be sure that when calling the string-related functions, you take care to use the n versions of the functions, like strncpy(...) , so that you can help protect yourself from buffer overruns.
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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
There's one thing you shouldn't forget. that's to delete the "new"ly allocated buffers.
But,std::strings. Just awesome.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I am working on a project, where i have to catch event on Update of the particular control , message is already defined for it.
Between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP i am putting
ON_MESSAGE (Messagename,UpdateFunction) statement with message and function name as a parameter.
i have written definition of UpdateFunction in the same class.
Problem is while running and updating control UpdateFunction is not getting executed.
is there anything i am missing for handling this ?
|
|
|
|
|
Do you SendMessage or PostMessage to the class that you defined message in it or the framework should do that for you?
Did you define a custom message or just redirect the same message?
Which message is it? What type of control? Is it a custom control for example?
Would you please provide some of your codes or at least more details.
// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
yah its a custom control and message is also a custom one , redirecting to other message ... , i mean to say that its a custom table control when i update a cell value it should get to that method which i have specified in On_Message ...
I just wanted to ask that is there anything that we have to do while handling messages
1)Define entry in message map
2)provide declaration and definition of Method (which you want to execute on event of message)
Tahnx
|
|
|
|
|
paresh_joe wrote: anything that we have to do while handling messages
If it's a CUSTOM message, then we shall follow the instruction:
1. Event handler MUST return LRESULT
2. Message variable should be defined in a right way, easiest: #define MyTestMessage WM_USER+1
3. Function declaration in the header file should should be written before DECLARE_MESSAGE_MAP() (e.g LRESULT OnSomething(WPARAM wParam, LPARAM lParam); )
4. In .cpp it should be declared in a MESSAGE_MAP block: (e.g.ON_MESSAGE(MyTestMessage, OnSomthing))
5. ALWAYS return 0 in the message handler function.
6. Only a window can accept messages, unless you create a custom message mapping, sending, dispatching, ... mechanism. So a CWnd object or derived classes can handle a message.
...
LRESULT OnSomething(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
...
BEGIN_MESSAGE_MAP(CMyClass, CDialog)
...
ON_MESSAGE(MyTestMessage, OnSomething)
END_MESSAGE_MAP()
.
.
.
LRESULT CMyClass::OnSometing(WPARAM wParam, LPARAM lParam)
{
return 0;
}
// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive) { cout<<"I love programming."; }
modified on Friday, December 07, 2007 9:29:01 AM
|
|
|
|
|
|
Dear colleagues,
I have a big project-solution (MFC-based), compounded of many dlls (in their own dll-projects).
All dlls have resources in their resource-files (*.rc; resource.h). Now I now from experience that there can be a lot of problems with resource-ID conflicts and much more.
Can you give me any hint how to tackle this problem?
Thank you in advance for your hints
modified on Friday, December 07, 2007 6:25:24 AM
|
|
|
|
|
For conflicts in the same resource file you can use
Resource ID Organiser[^] by Anna jayne
// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Thank you !
This guides to my next question: What is with conflicts in different resource-files.
|
|
|
|
|
Hi.... I have created a SDI Application. I want a Dialog to be appeared on the top of the Document. Can anybody help me out?
|
|
|
|
|
have you tried something yet ?
is CDialog::DoModal() of any help ?
|
|
|
|
|
Hi All,
I'm looking for an unmanaged memory profiler which *also* tracks pages (to the page file). Is there such a product?
Jeff
|
|
|
|
|
Perfmon? :P
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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Sorry Wrong Line
Bram van Kampen
|
|
|
|
|
What do you mean 'Unmanaged Memory'? Is that the stuff you forgot to free before you lost the pointer?
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: Is that the stuff you forgot to free before you lost the pointer?
If I could have voted 6, I would have (there's no bug in the new site to exploit in votiong twice either
I want watch a particular chunk of memory. Specifically, I need to know if a block obtained from AWE extensions is being paged out. I also want to compare overall paging (without AWE extension acquired) with the page I am trying to lock into memory.
Jeff
|
|
|
|
|
Jeffrey Walton wrote: Specifically, I need to know if a block obtained from AWE extensions is being paged out.
That's easy to answer. It can't be. Memory gained from AWE extensions is mapped directly into your process address space and is no longer managed by the OS.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Hi Mike,
Mike Dimmick wrote: That's easy to answer. It can't be.
I think I have to break down and use Windgb or cdb. I was trying to avoid it, sice I don't know any of the MM command. Yuk...
|
|
|
|