1 registered members (AndrewAMD),
718
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
str_cpy bug?
#436619
01/30/14 07:53
01/30/14 07:53
|
Joined: Dec 2010
Posts: 224 NRW, Germany
NeoJones
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 224
NRW, Germany
|
Hi! I have a problem with the multiplayer workshop from AUM 74. In "multiplayer3.c" in line 80:
str_cpy(input_str, "#100"); // reset the input string
If I test it, there comes the text "#100" on enter key. But if I start the original server.bat and press the enter key, it works...!? I think, this is a bug? I have Version A8.40.3 Com Can anyone help me please?
Errors are the engine of progress.
Version: A8 Commercial OS: Win 7 64bit Models: Cinema 4D
|
|
|
Re: str_cpy bug?
[Re: NeoJones]
#436622
01/30/14 08:37
01/30/14 08:37
|
Joined: Dec 2010
Posts: 224 NRW, Germany
NeoJones
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 224
NRW, Germany
|
Ok, I find it myself. Its not a bug. Here is my solution: I changed:
str_cpy(input_str, "#100"); // reset the input string
with this:
str_cpy((input_txt.pstring)[0], str_create("#100")); // reset the input string
I think for TEXT objects its better you work with pstring.
Errors are the engine of progress.
Version: A8 Commercial OS: Win 7 64bit Models: Cinema 4D
|
|
|
Re: str_cpy bug?
[Re: sivan]
#436650
01/30/14 18:00
01/30/14 18:00
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Ouh, your "solution" leaks memory.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: str_cpy bug?
[Re: WretchedSid]
#436655
01/30/14 19:09
01/30/14 19:09
|
Joined: Dec 2010
Posts: 224 NRW, Germany
NeoJones
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 224
NRW, Germany
|
Thanks for your replies. yes, but it works for Me. sid Do you know a better way?
Last edited by Dragonfly; 01/30/14 19:13.
Errors are the engine of progress.
Version: A8 Commercial OS: Win 7 64bit Models: Cinema 4D
|
|
|
Re: str_cpy bug?
[Re: NeoJones]
#436715
01/31/14 18:07
01/31/14 18:07
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
yes, but it works for Me. That sounds like a fundamental lack of knowledge in regards to memory management. Which is bad the second you start playing with dynamically allocated memory. sid Do you know a better way? Yes. But you should google "memory leak" and use the manual to find out why it is a memory leak, what's so bad about it and how it's fixed.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: str_cpy bug?
[Re: WretchedSid]
#436750
02/01/14 05:16
02/01/14 05:16
|
Joined: Dec 2010
Posts: 224 NRW, Germany
NeoJones
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 224
NRW, Germany
|
Ok, but I really don't understand, why you can't explain me about the problem. I asked google for that, but I dont understand, whats the problem here. This line:
str_cpy(input_str, "#100"); // reset the input string
is the original code of the workshop in AUM 74.
Errors are the engine of progress.
Version: A8 Commercial OS: Win 7 64bit Models: Cinema 4D
|
|
|
Re: str_cpy bug?
[Re: NeoJones]
#436756
02/01/14 10:47
02/01/14 10:47
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Yes, this code creates the string once. Yours creates a new string every time you call it.
POTATO-MAN saves the day! - Random
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|