diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/grolbp/lbp.cc | 25 | ||||
-rw-r--r-- | src/preproc/html/pre-html.cc | 27 |
2 files changed, 15 insertions, 37 deletions
diff --git a/src/devices/grolbp/lbp.cc b/src/devices/grolbp/lbp.cc index ec8c7b1f..376324b6 100644 --- a/src/devices/grolbp/lbp.cc +++ b/src/devices/grolbp/lbp.cc @@ -98,19 +98,6 @@ static char *strsep(char **pcadena, const char *delim) }; #endif -#ifndef HAVE_STRDUP -// Ditto with OS/390 and strdup -static char *strdup(const char *s) -{ - char *result; - - result = (char *)malloc(strlen(s)+1); - if (result != NULL) strcpy(result,s); - return result; - -}; // strdup - -#endif lbp_font::lbp_font(const char *nm) : font(nm) { @@ -580,20 +567,20 @@ static int set_papersize(const char *papersize) *p1, *papsize; - p = papsize = strdup(&papersize[4]); + p = papsize = strsave(&papersize[4]); if (papsize == NULL) return -1; p1 = strsep(&p,"x"); if (p == NULL) { // let's test for an uppercase x p = papsize ; p1 = strsep(&p,"X"); - if (p == NULL) { free(papsize); return -1;}; + if (p == NULL) { a_delete papsize; return -1;}; }; // if (p1 == NULL) paperlength = atoi(p1); - if (paperlength == 0) { free(papsize); return -1;}; + if (paperlength == 0) { a_delete papsize; return -1;}; paperwidth = atoi(p); - if (paperwidth == 0) { free(papsize); return -1;}; - free(papsize); + if (paperwidth == 0) { a_delete papsize; return -1;}; + a_delete papsize; return 82; }; // if (strcnasecmp("cust",papersize,4) == 0) @@ -692,7 +679,7 @@ static void usage(FILE *stream) int main(int argc, char **argv) { - if (program_name == NULL) program_name = strdup(argv[0]); + if (program_name == NULL) program_name = strsave(argv[0]); font::set_unknown_desc_command_handler(handle_unknown_desc_command); // command line parsing diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc index b4b3ea3d..dcb234f4 100644 --- a/src/preproc/html/pre-html.cc +++ b/src/preproc/html/pre-html.cc @@ -190,9 +190,7 @@ make_message (const char *fmt, ...) /* If that worked, return the string. */ if (n > -1 && n < size) { if (size > n+1) { - np = strdup(p); - if (np == NULL) - sys_fatal("strdup"); + np = strsave(p); free(p); return np; } @@ -268,7 +266,7 @@ intToStr (int i) char * make_message (const char *fmt, ...) { - char *p = strdup(fmt); /* so we can splat a nul anywhere in the string */ + char *p = strsave(fmt); /* so we can splat a nul anywhere in the string */ char *np; char *l; char *s; @@ -276,9 +274,6 @@ make_message (const char *fmt, ...) int search=0; va_list ap; - if (p == NULL) - sys_fatal("strdup"); - va_start(ap, fmt); while (p) { int lenp=strlen(p); @@ -294,9 +289,7 @@ make_message (const char *fmt, ...) switch (*(f+1)) { case 'd': - l = strdup(f+2); - if (l == NULL) - sys_fatal("strdup"); + l = strsave(f+2); *f = (char)0; num = intToStr(va_arg(ap, int)); np = (char *)malloc(strlen(p)+strlen(num)+strlen(l)+1); @@ -307,13 +300,11 @@ make_message (const char *fmt, ...) strcat(np, l); search += strlen(np)-lenp; free(num); - free(l); + a_delete l; break; case 's': /* concat */ l = f+2; - if (l == NULL) - sys_fatal("strdup"); s = va_arg(ap, char *); *f = (char)0; np = (char *)malloc(strlen(l)+1+strlen(p)+strlen(s)); @@ -339,7 +330,7 @@ make_message (const char *fmt, ...) sys_fatal("unexpected format specifier"); return NULL; } - free(p); + a_delete p; p = np; } va_end(ap); @@ -507,7 +498,7 @@ static void makeFileName (void) sys_fatal("malloc"); strcpy(image_template, s); strcat(image_template, "-%d"); - free(s); + a_delete s; } /* @@ -890,7 +881,7 @@ static int createAllPages (void) fflush(stderr); #endif html_system(s, 1); - free(s); + a_delete s; return 0; } @@ -906,7 +897,7 @@ static void removeAllPages (void) do { if (s) - free(s); + a_delete s; s = make_message("%s/%d", imagePageStem, i); if (s == NULL) sys_fatal("make_message"); @@ -970,7 +961,7 @@ static void createImage (imageItem *i) fprintf(stderr, s); #endif html_system(s, 0); - free(s); + a_delete s; #if defined(DEBUGGING) } else { fprintf(stderr, "ignoring image as x1 coord is -1\n"); |