Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > malloc() for struct member

Reply
Thread Tools

malloc() for struct member

 
 
Baxter
Guest
Posts: n/a
 
      10-07-2005
After you free the memory, set the member variable to NULL and see if that
changes anything.

When you start getting weird errors/crashes, it's usually worthwhile to look
for buffer overruns, freeing memory that has already been freed, and things
like that.

--
---------------------------------------------------------------------
DataGet & PocketLog www.dataget.com
Data Collectors www.baxcode.com
--------------------------------------------------------------------



"googler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> > What prompted the question?

>
> A code like the one I gave resulted in a crash. That's why I posted the
> question. My main point was if allocating and freeing memory is OK when
> done on a struct member (I knew it's OK, but the above crash made me a
> bit confused).
>
> I presume it's a compilation problem since the release build works and
> the crash happens for debug build (which is weird since it is usually
> the other way round).
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
pointer to a member of a struct which is in turn a member of an arrayof structs pete142 C Programming 5 01-23-2008 01:11 AM
Using an instance of a struct as a member of that struct dutchgoldtony C Programming 15 11-16-2005 11:24 PM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM



Advertisments