Memory Fault
Sys Admin
gh at S5000.UUCP
Fri Jul 20 00:06:04 AEST 1990
I got this code from sactoh0!jak (Jay A. Konigsberg)
he wrote the simped editor
when I run simped and try to put any lines in to the file or read any lines
in a existing file I get a core dump
This is the Stack Trace from sdb
------------------------------------------------------------------------
Core file 'core' Memory Fault (11) at
14 files, 14 procedures.
0x8319c in strdup:23: buffer[stringinx] = string[stringinx];
>strdup(string="Now is the time.") [strdup.c:23]
allocate()
addlines(text=0x092d44,overflow=Data address not found
>
------------------------------------------------------------------------
This is the code for strdup.c
any help is appreciated
/*
* strdup - duplicate a string using malloc
* CODE NOT TESTED, HOWEVER IT SHOULD WORK FINE FOR simped.
* ===============
*/
#include "simped.h"
char *strdup(string)
char *string;
{
/*static char *buffer;*/
char *buffer, *malloc();
int stringinx;
if (buffer = (char *) malloc(strlen(string)) == NULL)
{
fprintf(stderr, "malloc: in strdup, error\n");
exit(2);
}
for (stringinx=0; stringinx <= strlen(string); ++stringinx)
buffer[stringinx] = string[stringinx];
return(buffer);
}
_____________________________________Glen_______________________________________
______________________________Lexington__Oklahoma_______________________________
______________________{uunet uunet.uu.net}!uokmax!S5000!gh______________________
--
_____________________________________Glen_______________________________________
______________________________Lexington__Oklahoma_______________________________
______________________{uunet uunet.uu.net}!uokmax!S5000!gh______________________
More information about the Comp.lang.c
mailing list