Re: Memory allocation troubles- i think

From: George Greer (
Date: 12/14/00

On Thu, 14 Dec 2000, RJ Bean wrote:

>but when I attempt to allocate the memory, i think i'm encountering a
>problem.  Nowhere can i find any good documentation on the malloc
>statement. I first tried using 'new' but i got undeclared identifier.  I
>assumed that since its of .c extension.  I must resort to the 'C' malloc
>and free.

Instead of:

  new_rec_ptr = (struct known_char_node *) malloc((sizeof(struct known_char_node)) + 1);

you can use:

  CREATE(new_rec_ptr, struct known_char_node, 1);

You also don't need the +1 on your sizeof.

>I found the crashing line using log statements [...]

Other people helped with that. (Allocate the 'char*' too.)

George Greer            | If it's about the CircleMUD mailing list,   | mail instead.

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 04/11/01 PDT