You aren't understanding my problem.
I never mentioned anything about fwrite()ing anything.
ok, i changed load_char to get rid of char_file_u
ie load_char is prototyped like this now.
int load_char(char *arg, struct char_data *player);
I hope you understand at this point.
the problem I keep having though is something like a memory error.
to use load_char() now, I must CREATE() the char_data structure before
sending it to load_char().
anyway, here's a simple loop that has the idea i'm talking about.
for (i = 0; i <= top_of_ptable; i++) {
CREATE(tch, struct char_data, 1);
if ((load_char(&player_table[i].name, tch)) < 0)
{ FREE(tch); continue; }
else {
do something with the character such as do_stat_character.
or print certain info to a buffer for showing to a character later.
}
free_char(tch);
}
anyway, after about a few of these being run consistently,
I get a memory error in malloc (or calloc, whatever).
and it's never in a FREE() of anykind, it's in a CREATE() or str_dup()
I'm thinking, that I'm CREATE()ing and FREE()ing too much too quickly.
I only have 200 players (half of them don't even play anymore).
and currently, I've had to change the loop to something like so:
CREATE(tch, char_data, 1);
for (i = 0; i <= top_of_ptable; i++) {
if ((load_char(&player_table[i].name, tch)) < 0)
continue;
else {
do the stuff as usual
}
}
if (tch)
free_char(tch);
Memory Correct (similar to Politically correct) means to free() whatever
you CREATE().
I'm hoping to memory correct with this, but currently I can't find a way
around it.
Thanks for any help..
Code On
Akuma the Raging Coder
At 06:13 PM 3/16/98 -0500, you wrote:
>On Mon, 16 Mar 1998, Akuma/Chris Baggett/DOOMer wrote:
>
>>The char_data structure is that same as it always was.
>>many things added, but nothing removed, all I did
>>was make load_char (i have ASCII pfiles) accept
>>a char_data structure instead of a char_file_u structure.
>
>I think what Daniel means is you cannot fwrite() a pointer, you can only
>write character arrays. (Technically, you _can_ write the pointer, it just
>won't point at the same stuff when you read it back in...)
>
>--
>George Greer - Me@Null.net | Genius may have its limitations, but
stupidity
>http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard
>
>
> +------------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
> +------------------------------------------------------------+
>
>
+------------------------------------------------------------+
| "The poets talk about love, but what I talk about is DOOM, |
| because in the end, DOOM is all that counts." - |
| Alex Machine/George Stark/Stephen King, The Dark Half |
| "Nothing is IMPOSSIBLE, Just IMPROBABLE" |
| "Easier Said Than Done, But Better Done Than Said..." |
+------------------------------------------------------------+
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST