| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Need to copy |
In a message dated 10-22-98, James Mckenzie said to David Noon about "Need
to copy"
Hi James,
[snip]
JM>finally the code at the beginning of calc_offered_load:
JM>void calc_offered_load (EXPT_DESC_PTR expt)
JM>{
JM> /* Copy of experiment description structure used for offered load
JM> * calculation */
JM> EXPT_DESC ol_ex;
JM> int i;
JM> double def_off_load, off_load;
JM> double avg_ol;
JM> int saved_debug_level;
JM> char *copyptr;
JM>if (verbose) fprintf (outfile, "\n*** Calculating offered
load.***\n\n");
JM>
JM> #ifdef DEBUG_SUPPORT
JM> saved_debug_level = debug_level;
JM> if (!(debug_level & DEBUG_OFFLD)) debug_level = DEBUG_OFF;
JM> #endif /* DEBUG_SUPPORT */
JM>/**/ //bcopy ((char *) expt, (char *) &ol_ex, sizeof (EXPT_DESC));
JM>/*original unix code */
Ugly, but will work for POSIX-compliant compilers/libraries.
JM>// copyptr = (char *) memcpy (&ol_ex, expt, sizeof (EXPT_DESC));
JM>/* code modified for use under DOS/OS2 by
JM>original author. Results in a SYS1808 error */
The above is sort of correct. Your compiler might be returning NULL when it
should be returning a valid address as a void *. I don't bother checking
memcpy() calls, as that is why we have protection hardware for memory.
JM>// copyptr = (char *) memmove (&ol_ex, expt, sizeof (expt));
JM>/*This "works" except INT variables end up with incorrect values*/
The above has the wrong 3rd argument. It should be sizeof(EXPT_DESC).
JM>// if (!copyptr) {
JM>// fprintf (stderr, "Experiment file copy failed \n");
JM>// exit (1);
JM>// }
JM>old_ex = ex;
JM>/*This works with all values as they are in ex*/
This is a reference to the global storage. It will work, but makes no use of
your expt parameter so it is far less flexible.
You might also try:
old_ex = *expt;
Regards
Dave
___
* MR/2 2.25 #353 * HAL 9000: "Help me, Dave. I can't run under Windows."
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4)SEEN-BY: 396/1 632/0 371 633/210 260 267 270 371 635/506 728 639/252 670/218 @PATH: 440/4 255/1 251/25 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.