/* Send a page to one char. */
void page_send( const char *txt, character_data * ch )
{
descriptor_data *d;
if( !ch )
{
sstm_log(LOG_BUG, "page_send: Null Character!" );
return;
}
if( NullString(txt) || ( d = ch->desc ) == NULL )
return;
if( ch->lines == 0 )
{
send_ch( txt, ch );
return;
}
/*
* If there is already some data being "paged" for this descriptor,
* append the new string.
*/
if( !NullString( d->showstr_head ) )
{
char *fub;
int i;
int size_new = strlen( txt ) + strlen( d->showstr_head ) + 2;
fub = new char[size_new];
fub[0] = '\0';
mudstrlcat( fub, d->showstr_head, size_new );
i = strlen( fub ) - strlen( d->showstr_point );
mudstrlcat( fub, txt, size_new );
ReplaceString( d->showstr_head, fub );
d->showstr_point = d->showstr_head + i;
CleanData(fub);
return;
}
ReplaceString( d->showstr_head, txt );
d->showstr_point = d->showstr_head;
page_string( d, "" );
return;
}
#define ReplaceString( p_str, n_str ) \
do \
{ \
if(!NullString(p_str)) \
{\
CleanData(p_str); \
} \
p_str = StrDup( (n_str) ); \
} while(0)
// Crazy Enhanced System! Makes life alittle simpler one would think.
// Always makes (point) = NULL.
// Darien 27/Aug/2006 0:44
#define CleanData(point) \
do \
{ \
if(point) \
{ \
if(typeid(point) == typeid(char *) || typeid(point) == typeid(const char *)) \
{ \
delete [] point; \
} \
else \
{ \
delete (point);\
} \
(point) = NULL; \
}\
else \
{ \
mud_debug(DEBUG_MEMORY,"CleanData: Trying to clean null Data from file %s: function: %s: lines: %d", __FILE__, __PRETTY_FUNCTION__, __LINE__); \
(point) = NULL; \
} \
} while(0)
// samson helped here :P only a little :P I swear :P
char *StrDup( const char *str )
{
static char *ret;
if(NullString(str))
{
mud_debug(DEBUG_MEMORY, "StrDup: Called with Null STR");
return NULL;
}
ret = new char[strlen(str)+1];
mudstrlcpy(ret, str, strlen(str)+1);
return ret;
}
#include <malloc.h>
int main(){
int* pint = new int;
delete pint;
pint = (int*)malloc(sizeof(int));
free(pint);
return 0;
}
; 2 : int main(){
; 3 : int* pint = new int;
push 4
call ??2@YAPAXI@Z ; operator new
add esp, 4
; 4 : delete pint;
push eax
call ??3@YAXPAX@Z ; operator delete
add esp, 4
; 5 : pint = (int*)malloc(sizeof(int));
push 4
call _malloc
add esp, 4
; 6 : free(pint);
push eax
call _free
add esp, 4
xor eax, eax
; 7 : return 0;
; 8 : }
ret 0
00401004 push 00000004
00401006 call 004010e0 ; operator new
0040100b add esp,00000004
0040100e push eax
0040100f call 004010d0 ; operator delete
00401014 add esp,00000004
00401017 push 00000004
00401019 call 00401050 ; malloc()
0040101e add esp,00000004
00401021 push eax
00401022 call 00401030 ; free()
00401027 add esp,00000004
0040102a xor eax,eax
0040102c pop edi
0040102d pop esi
0040102e pop ebx
0040102f ret
004010d0 mov eax,dword ptr [esp+04] ; the size arg
004010d4 push eax
004010d5 call 00401030 ; free()
004010da add esp,00000004
004010dd ret
004010e0 mov eax,dword ptr [esp+04]
004010e4 push 00000001
004010e6 push eax
004010e7 call 00401070 ; _nh_malloc()
004010ec add esp,00000008
004010ef ret
00401050 mov eax,dword ptr [00404048] ; _newmode
00401055 mov ecx,dword ptr [esp+04]
00401059 push eax
0040105a push ecx
0040105b call 00401070 ; _nh_malloc()
00401060 add esp,00000008
00401063 ret
The red line is the one erroring out, I used macros for ease of me knowing where i was at during the whole conversion, i have totally wiped out any allocs in the MUD, and replaced em with these macros:
is the error, im not sure why its doing it :(