Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ malloc in C++
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Jason
(109 posts) Bio
|
Date
| Sun 27 Apr 2014 05:21 PM (UTC) Amended on Sun 27 Apr 2014 05:29 PM (UTC) by Jason
|
Message
| ok I am using a SWFOTEFUSS code base that compiles in C++ (which I am COMPLETELY NEW to C++), but I wanted to update my changes code from the basic that is with swfotefuss so I grabbed the snippet. When I try to compile I get these errors now:
Compiling o/changes.o....
changes.c: In function `void load_changes()':
changes.c:86: invalid conversion from `void*' to `CHANGE_DATA*'
changes.c: In function `void delete_change(int)':
changes.c:144: invalid conversion from `void*' to `CHANGE_DATA*'
changes.c: In function `void do_addchange(CHAR_DATA*, const char*)':
changes.c:185: invalid conversion from `void*' to `CHANGE_DATA*'
Which the these are referring to malloc and realloc from c
To my understanding, C++ does not need these. So my question is how would I fix these:
From load changes
changes_table = malloc( sizeof (CHANGE_DATA) * (maxChanges+1) );<--------This line
for( i = 0; i < maxChanges; i++ )
{
changes_table.change = fread_string( fp );
changes_table.coder = fread_string( fp );
changes_table.date = fread_string( fp );
changes_table.mudtime = fread_number( fp );
}
From delete change:
new_table = malloc( sizeof( CHANGE_DATA ) * maxChanges );<-----This line
if( !new_table )
{
return;
}
From do_addchange
new_table = realloc( changes_table, sizeof( CHANGE_DATA ) *(maxChanges+1) );<-----This Line
if (!new_table) /* realloc failed */
{
send_to_char ("Memory allocation failed. Brace for impact.\n\r",ch);
return;
}
Any help would be great... I'm still learning so please bare with me. | Top |
|
Posted by
| Jason
(109 posts) Bio
|
Date
| Reply #1 on Sun 27 Apr 2014 07:09 PM (UTC) |
Message
| Nevermind.... I got it... I'm a moron.... | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
9,698 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top