Changed all string allocations to charalloc(), new function designed to take nmalloc argument but call calloc based on (char *) size.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@661 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2001-05-17 11:35:43 +00:00
parent 9fe015cca3
commit 88b091510b
9 changed files with 58 additions and 54 deletions

View File

@ -20,6 +20,9 @@ Cvs code -
- Added config.guess and config.sub to distribution because, - Added config.guess and config.sub to distribution because,
apparently, newer autoconf/automakes can't live without them. apparently, newer autoconf/automakes can't live without them.
- Various spelling updates by David Lawrence Ramsey. - Various spelling updates by David Lawrence Ramsey.
- Changed all string allocations to charalloc(), new function
designed to take nmalloc argument but call calloc based on
(char *) size.
- configure.in: - configure.in:
- New option, --enable-nanorc, which allows people to have a .nanorc - New option, --enable-nanorc, which allows people to have a .nanorc
initialization file and set options normally used on the command initialization file and set options normally used on the command

18
cut.c
View File

@ -66,13 +66,13 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
/* Set up the beginning of the cutbuffer */ /* Set up the beginning of the cutbuffer */
tmp = copy_node(top); tmp = copy_node(top);
tmpstr = nmalloc(strlen(&top->data[top_x]) + 1); tmpstr = charalloc(strlen(&top->data[top_x]) + 1);
strcpy(tmpstr, &top->data[top_x]); strcpy(tmpstr, &top->data[top_x]);
free(tmp->data); free(tmp->data);
tmp->data = tmpstr; tmp->data = tmpstr;
/* Chop off the end of the first line */ /* Chop off the end of the first line */
tmpstr = nmalloc(top_x + 1); tmpstr = charalloc(top_x + 1);
strncpy(tmpstr, top->data, top_x); strncpy(tmpstr, top->data, top_x);
free(top->data); free(top->data);
top->data = tmpstr; top->data = tmpstr;
@ -90,7 +90,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
if (next == NULL) if (next == NULL)
return; return;
/* Now, paste bot[bot_x] into top[top_x] */ /* Now, paste bot[bot_x] into top[top_x] */
tmpstr = nmalloc(strlen(top->data) + strlen(&bot->data[bot_x])); tmpstr = charalloc(strlen(top->data) + strlen(&bot->data[bot_x]));
strncpy(tmpstr, top->data, top_x); strncpy(tmpstr, top->data, top_x);
strcpy(&tmpstr[top_x], &bot->data[bot_x]); strcpy(&tmpstr[top_x], &bot->data[bot_x]);
free(top->data); free(top->data);
@ -182,7 +182,7 @@ int do_cut_text(void)
tmp = copy_node(current); tmp = copy_node(current);
newsize = abs(mark_beginx - current_x) + 1; newsize = abs(mark_beginx - current_x) + 1;
tmpstr = nmalloc(newsize + 1); tmpstr = charalloc(newsize + 1);
if (current_x < mark_beginx) { if (current_x < mark_beginx) {
strncpy(tmpstr, &current->data[current_x], newsize); strncpy(tmpstr, &current->data[current_x], newsize);
memmove(&current->data[current_x], memmove(&current->data[current_x],
@ -237,7 +237,7 @@ int do_cut_text(void)
} else { } else {
add_to_cutbuffer(fileptr); add_to_cutbuffer(fileptr);
fileage = make_new_node(NULL); fileage = make_new_node(NULL);
fileage->data = nmalloc(1); fileage->data = charalloc(1);
fileage->data[0] = '\0'; fileage->data[0] = '\0';
current = fileage; current = fileage;
} }
@ -300,7 +300,7 @@ int do_uncut_text(void)
/* If there's only one line in the cutbuffer */ /* If there's only one line in the cutbuffer */
if (cutbuffer->next == NULL) { if (cutbuffer->next == NULL) {
tmpstr = tmpstr =
nmalloc(strlen(current->data) + strlen(cutbuffer->data) + charalloc(strlen(current->data) + strlen(cutbuffer->data) +
1); 1);
strncpy(tmpstr, current->data, current_x); strncpy(tmpstr, current->data, current_x);
strcpy(&tmpstr[current_x], cutbuffer->data); strcpy(&tmpstr[current_x], cutbuffer->data);
@ -315,13 +315,13 @@ int do_uncut_text(void)
} else { /* yuck -- no kidding! */ } else { /* yuck -- no kidding! */
tmp = current->next; tmp = current->next;
/* New beginning */ /* New beginning */
tmpstr = nmalloc(current_x + strlen(newbuf->data) + 1); tmpstr = charalloc(current_x + strlen(newbuf->data) + 1);
strncpy(tmpstr, current->data, current_x); strncpy(tmpstr, current->data, current_x);
strcpy(&tmpstr[current_x], newbuf->data); strcpy(&tmpstr[current_x], newbuf->data);
totsize += strlen(newbuf->data) + strlen(newend->data) + 1; totsize += strlen(newbuf->data) + strlen(newend->data) + 1;
/* New end */ /* New end */
tmpstr2 = nmalloc(strlen(newend->data) + tmpstr2 = charalloc(strlen(newend->data) +
strlen(&current->data[current_x]) + 1); strlen(&current->data[current_x]) + 1);
strcpy(tmpstr2, newend->data); strcpy(tmpstr2, newend->data);
strcat(tmpstr2, &current->data[current_x]); strcat(tmpstr2, &current->data[current_x]);
@ -371,7 +371,7 @@ int do_uncut_text(void)
if (marked_cut == 2 && current_x != strlen(current->data)) { if (marked_cut == 2 && current_x != strlen(current->data)) {
tmp = make_new_node(current); tmp = make_new_node(current);
tmp->data = nmalloc(strlen(&current->data[current_x]) + 1); tmp->data = charalloc(strlen(&current->data[current_x]) + 1);
strcpy(tmp->data, &current->data[current_x]); strcpy(tmp->data, &current->data[current_x]);
splice_node(current, tmp, current->next); splice_node(current, tmp, current->next);
null_at(current->data, current_x); null_at(current->data, current_x);

24
files.c
View File

@ -54,7 +54,7 @@ void load_file(void)
void new_file(void) void new_file(void)
{ {
fileage = nmalloc(sizeof(filestruct)); fileage = nmalloc(sizeof(filestruct));
fileage->data = nmalloc(1); fileage->data = charalloc(1);
strcpy(fileage->data, ""); strcpy(fileage->data, "");
fileage->prev = NULL; fileage->prev = NULL;
fileage->next = NULL; fileage->next = NULL;
@ -96,7 +96,7 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
filestruct *fileptr; filestruct *fileptr;
fileptr = nmalloc(sizeof(filestruct)); fileptr = nmalloc(sizeof(filestruct));
fileptr->data = nmalloc(strlen(buf) + 2); fileptr->data = charalloc(strlen(buf) + 2);
strcpy(fileptr->data, buf); strcpy(fileptr->data, buf);
if (*line1ins) { if (*line1ins) {
@ -137,7 +137,7 @@ int read_file(int fd, char *filename)
filestruct *fileptr = current, *tmp = NULL; filestruct *fileptr = current, *tmp = NULL;
int line1ins = 0; int line1ins = 0;
buf = nmalloc(bufx); buf = charalloc(bufx);
buf[0] = '\0'; buf[0] = '\0';
if (fileptr != NULL && fileptr->prev != NULL) { if (fileptr != NULL && fileptr->prev != NULL) {
@ -390,7 +390,7 @@ int write_file(char *name, int tmp)
} }
/* Don't follow symlink. Create new file. */ /* Don't follow symlink. Create new file. */
else { else {
buf = nmalloc(strlen(realname) + 8); buf = charalloc(strlen(realname) + 8);
strncpy(buf, realname, strlen(realname)+1); strncpy(buf, realname, strlen(realname)+1);
strcat(buf, ".XXXXXX"); strcat(buf, ".XXXXXX");
if ((fd = mkstemp(buf)) == -1) { if ((fd = mkstemp(buf)) == -1) {
@ -603,7 +603,7 @@ char *real_dir_from_tilde(char *buf)
if (getenv("HOME") != NULL) { if (getenv("HOME") != NULL) {
free(dirtmp); free(dirtmp);
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME"))); dirtmp = charalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]); sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]);
@ -627,7 +627,7 @@ char *real_dir_from_tilde(char *buf)
if (userdata != NULL) { /* User found */ if (userdata != NULL) { /* User found */
free(dirtmp); free(dirtmp);
dirtmp = nmalloc(strlen(buf) + 2 + strlen(userdata->pw_dir)); dirtmp = charalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]); sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
} }
@ -702,7 +702,7 @@ char **username_tab_completion(char *buf, int *num_matches)
* This makes a lot more sense to me (Chris) this way... * This makes a lot more sense to me (Chris) this way...
*/ */
matchline = nmalloc(strlen(userdata->pw_name) + 2); matchline = charalloc(strlen(userdata->pw_name) + 2);
sprintf(matchline, "~%s", userdata->pw_name); sprintf(matchline, "~%s", userdata->pw_name);
matches[*num_matches] = matchline; matches[*num_matches] = matchline;
++*num_matches; ++*num_matches;
@ -734,7 +734,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
/* Okie, if there's a / in the buffer, strip out the directory part */ /* Okie, if there's a / in the buffer, strip out the directory part */
if (strcmp(buf, "") && strstr(buf, "/")) { if (strcmp(buf, "") && strstr(buf, "/")) {
dirName = nmalloc(strlen(buf) + 1); dirName = charalloc(strlen(buf) + 1);
tmp = buf + strlen(buf); tmp = buf + strlen(buf);
while (*tmp != '/' && tmp != buf) while (*tmp != '/' && tmp != buf)
tmp--; tmp--;
@ -793,7 +793,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
* This makes a lot more sense to me (Chris) this way... * This makes a lot more sense to me (Chris) this way...
*/ */
tmp2 = NULL; tmp2 = NULL;
tmp2 = nmalloc(strlen(next->d_name) + 1); tmp2 = charalloc(strlen(next->d_name) + 1);
strcpy(tmp2, next->d_name); strcpy(tmp2, next->d_name);
matches[*num_matches] = tmp2; matches[*num_matches] = tmp2;
++*num_matches; ++*num_matches;
@ -958,7 +958,7 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
if (longestname > COLS - 1) if (longestname > COLS - 1)
longestname = COLS - 1; longestname = COLS - 1;
foo = nmalloc(longestname + 5); foo = charalloc(longestname + 5);
/* Print the list of matches */ /* Print the list of matches */
for (i = 0, col = 0; i < num_matches; i++) { for (i = 0, col = 0; i < num_matches; i++) {
@ -1063,7 +1063,7 @@ char **browser_init(char *path, int *longest, int *numents)
while ((next = readdir(dir)) != NULL) { while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, ".")) if (!strcmp(next->d_name, "."))
continue; continue;
filelist[i] = nmalloc(strlen(next->d_name) + strlen(path) + 2); filelist[i] = charalloc(strlen(next->d_name) + strlen(path) + 2);
if (!strcmp(path, "/")) if (!strcmp(path, "/"))
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1, snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1,
@ -1158,7 +1158,7 @@ char *do_browser(char *inpath)
path = mallocstrcpy(path, inpath); path = mallocstrcpy(path, inpath);
filelist = browser_init(path, &longest, &numents); filelist = browser_init(path, &longest, &numents);
foo = nmalloc(longest + 8); foo = charalloc(longest + 8);
/* Sort the list by directory first, then alphabetically */ /* Sort the list by directory first, then alphabetically */
qsort(filelist, numents, sizeof(char *), diralphasort); qsort(filelist, numents, sizeof(char *), diralphasort);

35
nano.c
View File

@ -118,7 +118,7 @@ void die(char *msg, ...)
i = write_file(name, 1); i = write_file(name, 1);
} else { } else {
char *buf = nmalloc(strlen(filename) + 6); char *buf = charalloc(strlen(filename) + 6);
strcpy(buf, filename); strcpy(buf, filename);
strcat(buf, ".save"); strcat(buf, ".save");
i = write_file(buf, 1); i = write_file(buf, 1);
@ -160,7 +160,7 @@ void clear_filename(void)
{ {
if (filename != NULL) if (filename != NULL)
free(filename); free(filename);
filename = nmalloc(1); filename = charalloc(1);
filename[0] = 0; filename[0] = 0;
} }
@ -187,7 +187,7 @@ void global_init(void)
if (fill < MIN_FILL_LENGTH) if (fill < MIN_FILL_LENGTH)
die_too_small(); die_too_small();
hblank = nmalloc(COLS + 1); hblank = charalloc(COLS + 1);
memset(hblank, ' ', COLS); memset(hblank, ' ', COLS);
hblank[COLS] = 0; hblank[COLS] = 0;
} }
@ -224,7 +224,7 @@ filestruct *copy_node(filestruct * src)
filestruct *dst; filestruct *dst;
dst = nmalloc(sizeof(filestruct)); dst = nmalloc(sizeof(filestruct));
dst->data = nmalloc(strlen(src->data) + 1); dst->data = charalloc(strlen(src->data) + 1);
dst->next = src->next; dst->next = src->next;
dst->prev = src->prev; dst->prev = src->prev;
@ -606,12 +606,12 @@ int do_enter(filestruct * inptr)
current_x++; current_x++;
totsize++; totsize++;
} }
newnode->data = nmalloc(strlen(tmp) + extra + 1); newnode->data = charalloc(strlen(tmp) + extra + 1);
strncpy(newnode->data, current->data, extra); strncpy(newnode->data, current->data, extra);
strcpy(&newnode->data[extra], tmp); strcpy(&newnode->data[extra], tmp);
} }
} else { } else {
newnode->data = nmalloc(strlen(tmp) + 1); newnode->data = charalloc(strlen(tmp) + 1);
strcpy(newnode->data, tmp); strcpy(newnode->data, tmp);
} }
*tmp = 0; *tmp = 0;
@ -809,7 +809,7 @@ void do_wrap(filestruct * inptr, char input_char)
down = 1; down = 1;
} }
temp->data = nmalloc(strlen(&inptr->data[current_word_start]) + 1); temp->data = charalloc(strlen(&inptr->data[current_word_start]) + 1);
strcpy(temp->data, &inptr->data[current_word_start]); strcpy(temp->data, &inptr->data[current_word_start]);
inptr->data = nrealloc(inptr->data, last_word_end + 2); inptr->data = nrealloc(inptr->data, last_word_end + 2);
inptr->data[last_word_end + 1] = 0; inptr->data[last_word_end + 1] = 0;
@ -817,7 +817,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* Category 1b: one word on the line and word not taking up whole line /* Category 1b: one word on the line and word not taking up whole line
(i.e. there are spaces at the beginning of the line) */ (i.e. there are spaces at the beginning of the line) */
if (last_word_end == -1) { if (last_word_end == -1) {
temp->data = nmalloc(strlen(&inptr->data[current_word_start]) + 1); temp->data = charalloc(strlen(&inptr->data[current_word_start]) + 1);
strcpy(temp->data, &inptr->data[current_word_start]); strcpy(temp->data, &inptr->data[current_word_start]);
/* Inside word, remove it from original, and move cursor to right spot. */ /* Inside word, remove it from original, and move cursor to right spot. */
@ -848,7 +848,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* Case 2a: cursor before word at wrap point. */ /* Case 2a: cursor before word at wrap point. */
if (current_x < current_word_start) { if (current_x < current_word_start) {
temp->data = temp->data =
nmalloc(strlen(&inptr->data[current_word_start]) + 1); charalloc(strlen(&inptr->data[current_word_start]) + 1);
strcpy(temp->data, &inptr->data[current_word_start]); strcpy(temp->data, &inptr->data[current_word_start]);
if (!isspace((int) input_char)) { if (!isspace((int) input_char)) {
@ -871,7 +871,7 @@ void do_wrap(filestruct * inptr, char input_char)
else if ((current_x >= current_word_start) else if ((current_x >= current_word_start)
&& (current_x <= (current_word_end + 1))) { && (current_x <= (current_word_end + 1))) {
temp->data = temp->data =
nmalloc(strlen(&inptr->data[current_word_start]) + 1); charalloc(strlen(&inptr->data[current_word_start]) + 1);
strcpy(temp->data, &inptr->data[current_word_start]); strcpy(temp->data, &inptr->data[current_word_start]);
down = 1; down = 1;
@ -907,7 +907,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* Case 2c: cursor past word at wrap point. */ /* Case 2c: cursor past word at wrap point. */
else { else {
temp->data = temp->data =
nmalloc(strlen(&inptr->data[current_word_start]) + 1); charalloc(strlen(&inptr->data[current_word_start]) + 1);
strcpy(temp->data, &inptr->data[current_word_start]); strcpy(temp->data, &inptr->data[current_word_start]);
down = 1; down = 1;
@ -931,8 +931,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* Plus one for the space which concatenates the two lines together plus 1 for \0. */ /* Plus one for the space which concatenates the two lines together plus 1 for \0. */
char *p = char *p =
nmalloc((strlen(temp->data) + strlen(inptr->next->data) + 2) charalloc((strlen(temp->data) + strlen(inptr->next->data) + 2));
* sizeof(char));
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
int non = 0; int non = 0;
@ -991,7 +990,7 @@ void do_wrap(filestruct * inptr, char input_char)
spc++; spc++;
totsize++; totsize++;
} }
t = nmalloc(strlen(temp->data) + extra + 1); t = charalloc(strlen(temp->data) + extra + 1);
strncpy(t, inptr->data, extra); strncpy(t, inptr->data, extra);
strcpy(t + extra, temp->data); strcpy(t + extra, temp->data);
free(temp->data); free(temp->data);
@ -1342,7 +1341,7 @@ int do_int_speller(char *tempfile_name)
return FALSE; return FALSE;
} }
read_buff = nmalloc(pipe_buff_size + 1); read_buff = charalloc(pipe_buff_size + 1);
/* Process the returned spelling errors */ /* Process the returned spelling errors */
@ -1960,7 +1959,7 @@ int do_justify(void)
current->data[i] = '\0'; current->data[i] = '\0';
len2 = strlen(current->data + i + 1); len2 = strlen(current->data + i + 1);
tmpline->data = nmalloc(len2 + 1); tmpline->data = charalloc(len2 + 1);
/* Skip the white space in current. */ /* Skip the white space in current. */
memcpy(tmpline->data, current->data + i + 1, len2); memcpy(tmpline->data, current->data + i + 1, len2);
@ -2078,7 +2077,7 @@ void help_init(void)
free(help_text); free(help_text);
/* Allocate space for the help text */ /* Allocate space for the help text */
help_text = nmalloc(allocsize); help_text = charalloc(allocsize);
/* Now add the text we want */ /* Now add the text we want */
strcpy(help_text, help_text_init); strcpy(help_text, help_text_init);
@ -2332,7 +2331,7 @@ int main(int argc, char *argv[])
break; break;
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
case 's': case 's':
alt_speller = nmalloc(strlen(optarg) + 1); alt_speller = charalloc(strlen(optarg) + 1);
strcpy(alt_speller, optarg); strcpy(alt_speller, optarg);
break; break;
#endif #endif

View File

@ -124,7 +124,6 @@ void center_cursor(void);
void bottombars(shortcut s[], int slen); void bottombars(shortcut s[], int slen);
void blank_statusbar_refresh(void); void blank_statusbar_refresh(void);
void *nmalloc (size_t howmuch); void *nmalloc (size_t howmuch);
void *ncalloc (size_t howmuch, size_t size);
void *mallocstrcpy(char *dest, char *src); void *mallocstrcpy(char *dest, char *src);
void wrap_reset(void); void wrap_reset(void);
void display_main_list(void); void display_main_list(void);
@ -168,6 +167,8 @@ int do_first_line(void), do_last_line(void);
int do_replace(void), do_help(void), do_enter_void(void); int do_replace(void), do_help(void), do_enter_void(void);
int keypad_on(WINDOW * win, int newval); int keypad_on(WINDOW * win, int newval);
char *charalloc (size_t howmuch);
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
char *do_browser(char *path); char *do_browser(char *path);
struct stat filestat(const char *path); struct stat filestat(const char *path);

View File

@ -216,7 +216,7 @@ void do_rcfile(void)
if (getenv("HOME") == NULL) if (getenv("HOME") == NULL)
return; return;
nanorc = nmalloc(strlen(getenv("HOME")) + 10); nanorc = charalloc(strlen(getenv("HOME")) + 10);
sprintf(nanorc, "%s/.nanorc", getenv("HOME")); sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
if (stat(nanorc, &fileinfo) == -1) { if (stat(nanorc, &fileinfo) == -1) {

View File

@ -55,11 +55,11 @@ void regexp_cleanup(void)
void search_init_globals(void) void search_init_globals(void)
{ {
if (last_search == NULL) { if (last_search == NULL) {
last_search = nmalloc(1); last_search = charalloc(1);
last_search[0] = 0; last_search[0] = 0;
} }
if (last_replace == NULL) { if (last_replace == NULL) {
last_replace = nmalloc(1); last_replace = charalloc(1);
last_replace[0] = 0; last_replace[0] = 0;
} }
} }
@ -79,7 +79,7 @@ int search_init(int replacing)
search_init_globals(); search_init_globals();
buf = nmalloc(strlen(last_search) + 5); buf = charalloc(strlen(last_search) + 5);
buf[0] = 0; buf[0] = 0;
/* Okay, fun time. backupstring is our holder for what is being /* Okay, fun time. backupstring is our holder for what is being
@ -447,7 +447,7 @@ char *replace_line(void)
} }
/* Create buffer */ /* Create buffer */
copy = nmalloc(new_line_size); copy = charalloc(new_line_size);
/* Head of Original Line */ /* Head of Original Line */
strncpy(copy, current->data, current_x); strncpy(copy, current->data, current_x);
@ -628,7 +628,7 @@ int do_replace(void)
} }
if (ISSET(PICO_MODE)) { if (ISSET(PICO_MODE)) {
buf = nmalloc(strlen(last_replace) + 5); buf = charalloc(strlen(last_replace) + 5);
if (strcmp(last_replace, "")) { if (strcmp(last_replace, "")) {
if (strlen(last_replace) > (COLS / 3)) { if (strlen(last_replace) > (COLS / 3)) {
strncpy(buf, last_replace, COLS / 3); strncpy(buf, last_replace, COLS / 3);

13
utils.c
View File

@ -99,17 +99,18 @@ void *nmalloc(size_t howmuch)
return r; return r;
} }
/* We're going to need this too */ /* We're going to need this too - Hopefully this will minimize
void *ncalloc(size_t howmuch, size_t size) the transition cost of moving to the apropriate function. */
char *charalloc(size_t howmuch)
{ {
void *r; void *r;
/* Panic save? */ /* Panic save? */
if (!(r = calloc(howmuch, size))) if (!(r = calloc(howmuch, sizeof (char *))))
die(_("nano: calloc: out of memory!")); die(_("nano: calloc: out of memory!"));
return r; return (char *) r;
} }
void *nrealloc(void *ptr, size_t howmuch) void *nrealloc(void *ptr, size_t howmuch)
@ -141,7 +142,7 @@ void *mallocstrcpy(char *dest, char *src)
return(dest); return(dest);
} }
dest = nmalloc(strlen(src) + 1); dest = charalloc(strlen(src) + 1);
strcpy(dest, src); strcpy(dest, src);
return dest; return dest;
@ -152,7 +153,7 @@ void *mallocstrcpy(char *dest, char *src)
void new_magicline(void) void new_magicline(void)
{ {
filebot->next = nmalloc(sizeof(filestruct)); filebot->next = nmalloc(sizeof(filestruct));
filebot->next->data = nmalloc(1); filebot->next->data = charalloc(1);
filebot->next->data[0] = '\0'; filebot->next->data[0] = '\0';
filebot->next->prev = filebot; filebot->next->prev = filebot;
filebot->next->next = NULL; filebot->next->next = NULL;

View File

@ -265,7 +265,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
int shift = 0; int shift = 0;
#endif #endif
inputbuf = nmalloc(strlen(def) + 1); inputbuf = charalloc(strlen(def) + 1);
inputbuf[0] = 0; inputbuf[0] = 0;
x_left = strlen(buf); x_left = strlen(buf);
@ -930,7 +930,7 @@ void update_line(filestruct * fileptr, int index)
realdata = fileptr->data; realdata = fileptr->data;
len = strlen(realdata); len = strlen(realdata);
fileptr->data = nmalloc(xpt(fileptr, len) + 1); fileptr->data = charalloc(xpt(fileptr, len) + 1);
pos = 0; pos = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {