|
|
quite... asking for precision, because i didn't understand his post.
|
|
|
|
|
I dont think its question but Im wordering he gets 3 votes(5)
|
|
|
|
|
dunno, but none from me, as long as i don't understand the post.
|
|
|
|
|
Sometime for example you answer to a message, your answer is perfect but you get a lower vote but sometime you say a word but you get 5 voted now I'm wordering why? like this he says why color is different ?
|
|
|
|
|
it was certainly humour. i don't this the guy was attempting to down me there
|
|
|
|
|
But I dont agree with you I believe you are successful and you will successful,you have a character that I like it I think you are frank and I think its good
|
|
|
|
|
thank you
let's keep it good then
|
|
|
|
|
WalderMort wrote: why did you change the colour to blue?
It's called a "hyperlink."
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to get an IP adress from the name of a camera in my network.I don't know what is the instruction.
I have the two but I used once a command that gives you the IP @ from an entrered name and I forgot it
salem ,c wiem.
|
|
|
|
|
salem wiem,
first of all, you should really read Beej's Guide to Network Programming[^].
i read it once i was at school, and it was really useful to begin with sockets.
for what you're looking for, the functions is gethostbyname() (cf. §4.10)
|
|
|
|
|
Hi all,
Iam trying to understand array of pointers and functions.
I tried doing the following but get warning messages. I have mentioned the warning message above the respective lines.
Can anyone help me fix it.?
Thanks in advance.
char * Names;<br />
int next = 0;<br />
char * list = "Abc";<br />
<br />
Names[ next ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
list = "cdefg";<br />
Names[ next+1 ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next+1 ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
printf("vsp list got is %s\n", Names[0] );<br />
printf("vsp list got is %s\n", Names[1] );<br />
|
|
|
|
|
The problem is that Names is not an array of pointers but a simple char array. If you want a pointer array, you need to write this: char** Names; instead.
Also, instead of memcpy, you can simply use strcpy for a char array (if it is a null terminated string but in your case it is).
So, in your code snippet, when you do Names[0] for example, you simply access a character, not a pointer. That's why you get all these warnings.
|
|
|
|
|
malloc() returns a void* pointer. you should cast it into char* in your case.
BTW, are you coding C or C++ ?
if C++, abandon malloc() /free() for new /delete ...
for the printf() warning, %s is waiting for a char* , which is exactly what Names is. you should change its declaration into char** Names or char* Names[]
|
|
|
|
|
Hi all,
thanks for ur help.i do in C. I have corrected the code and i get no warnings now. but i would like to know if the following way of coding and passing the address of the first pointer to funcB is threadsafe in multithreaded environment.
is the follwing way of coding correct?Any help?
<br />
funcA{<br />
char * Names[] = {};<br />
int next = 0;<br />
char * list = "Abc";<br />
<br />
<br />
Names[ next ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
list = "cdefg";<br />
Names[ next+1 ] = malloc( sizeof( char )*( strlen( list ) + 1 ) );<br />
memcpy( Names[ next+1 ],list,sizeof( char )*( strlen( list ) + 1 ) );<br />
<br />
printf("vsp list got is %s\n", Names[0] );<br />
printf("vsp list got is %s\n", Names[1] );<br />
<br />
funcB(....,...,(const char**)&Names);<br />
}<br />
<br />
funcB(...,...,const char ** names)<br />
{<br />
....<br />
...<br />
free( (char*)names[0]);<br />
free( (char*)names[1]);<br />
<br />
}<br />
<br />
<br />
|
|
|
|
|
the way of passing parameters to a function doesn't affect the "thread safety" of the code...
if the resource is potentially alterable by several threads at the same time, then each thread must lock the resource before using it (and of course releasing it then)...
|
|
|
|
|
Say, the pointer of arrays char** Names is used by many threads.
in which case, if i make a local copy of the names[0] and names[1] values inside funcB()
say,
funcB(...,...,char **names)<br />
{<br />
char ** buf;<br />
buf = names;<br />
<br />
<br />
free ((char*)names[0]);<br />
free ((char*)names[1]);<br />
}<br />
|
|
|
|
|
Names[ next ] dereferences the pointer, so it is actually a char . So when you try to assign a pointer to it (malloc returns void*), or assign it to a pointer (memcpy takes void*, %s as format string takes a char *), you try to assign an adress to to a value-type. This is of course not wrong, but it is most likely not what you want, hence the warning. The solution would be to declare char ** Names . Then you wold first have to allocate memory on Names with the size of the char * . Then you could allocate memory for Names[x] and do what you did here. I'm to lazy to write out the code here, also, figuring it out yourself is much better practice
Hope it helped a little.
|
|
|
|
|
I'm doing a program to solve the problem: find the k-shortest paths in a directed graph from source vertex s to destination vertex t.
Do you have some codes for this?
Please send me.
Thanks!
Nothing Is Impossible !
|
|
|
|
|
Hi all,
I'm trying to read(retrieving) and create xml files using MSXML.
I would like to enable validation before retrieving the xml with a perticular DTD.
The document that I use for retrieving the values does not have any DTD information. I need to specify the external file while loading the XML, and validate it. Please let me know if it is possible and if not possible, how to change the input XML file to contain DTD information.
Please guide me in this regard.
Thanks and regards,
raja pratap
|
|
|
|
|
I posted a similar question a while back without much luck, but it was the weekend
Take a look at this code sample
for ( int i=0; i<10; i++ )
{
HRGN hRgn = ::CreateRectRgn(0, 0, 10, 10);
::DeleteObject(hRgn);
}
A simple loop that opens a GDI handle then imideatly closes it. If I run the code and watch it in the task managers "GDI Objects" the results are confusing. I enter the loop with 4 handles and leave with 7. This figure will gradualy increase as I create more and more handles, so by the time my initialization is complete I have 400+ GDI objects.
My guess is that some sort of pool is used with a possible garbage collector, ie the handle is only freed as and when it is required. Could anybody please confirm this, and/or run the above example and tell me if you notice the same behaviour.
Obviously I don't have 400+ GDI objects, is there any way I can get the true count and/or force the task manager to update with the true figure?
|
|
|
|
|
I ran your simple loop in a dialog based app except I set it to loop 1000 times. The app started with 20 GDI objects and went up to 26 when I ran the loop once. It then stayed at 26 no matter how many times I ran the loop after that.
In your app, are you sure that you have SelectObject() ed the HRGN s out of the HDC s before you tried to DeleteObject()ed them? Any GDI object that is still selected into a DC will not be deleted by a call to DeleteObject() .
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
So far I have found this behaviour only relates to CreateRgn set of functions. As you probably know already my current project is very region intensive. Nowhere in my code do I directly SelectObject() a region into a DC, I always use the SetClip() set of functions and even those calls are made using global regions which will not be deleted.
It's safe to say that DeleteObject() is working and that there is no leakage, but can you imaging the feedback I would get when users take a look at the task manager?
|
|
|
|
|
Not seeing your code I can not tell for sure, but as you know any GDI object can cause this problem. Just because you use HRGNs extensively does not mean that is where the problem lies. I once had it with an icon in the title bar of a child window. One icon and it did not take long to have a couple hundred GDI objects just floating around. Look very carefully at all your GDI objects.
I do not know of a free tool that will point out which objects are leaking, so good luck in finding it.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: I do not know of a free tool that will point out which objects are leaking, so good luck in finding it.
This is the thing, there are no leaks. That code sample was placed on the very first line of my WinMain(), so no other objects are created and no DC's are present. The object does get deleted, but the count does not decrease to reflect the change. I have confirmed this by checking with "Task Manager" and the GetGuiResources() api call.
To detect memory leaks I am using Deleaker[^] which reports no errors.
|
|
|
|