links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 176f012195394294d52f9ca645affac0ea5fe5f7
Parent: 283d9602d9891576fdc08c82aaf7b79a4f473c8f
Author: Randy Palamar
Date:   Tue, 29 Nov 2022 22:39:43 -0700

links.h: remove init_str() function

Diffstat:
Mauth.c | 6+++---
Mbfu.c | 2+-
Mbookmark.c | 4++--
Mcache.c | 2+-
Mcharsets.c | 2+-
Mconnect.c | 2+-
Mdata.c | 4++--
Mdefault.c | 16++++++++--------
Mfile.c | 6+++---
Mhtml.c | 14+++++++-------
Mhtml_r.c | 4++--
Mhttp.c | 8++++----
Mhttps.c | 4++--
Mlinks.h | 9---------
Mmemory.c | 2+-
Mmenu.c | 6+++---
Msession.c | 18+++++++++---------
Mstring.c | 6+++++-
Mterminal.c | 8++++----
Mtypes.c | 6+++---
Murl.c | 14+++++++-------
Mview.c | 54++++++++++++++++++++++++++++--------------------------
22 files changed, 97 insertions(+), 100 deletions(-)

diff --git a/auth.c b/auth.c @@ -111,7 +111,7 @@ try_next: goto try_next; } q++; - r = init_str(); + r = NULL; l = 0; while (*q && *q != '"') { if (*q == '\\' && !*++q) @@ -133,7 +133,7 @@ auth_from_url(unsigned char *url, int proxy) password = get_pass(url); if (user && *user && password) { unsigned char *e = basic_encode(user, password); - r = init_str(); + r = NULL; if (proxy) add_to_str(&r, &l, cast_uchar "Proxy-"); add_to_str(&r, &l, cast_uchar "Authorization: Basic "); @@ -184,7 +184,7 @@ get_auth_string(unsigned char *url, int proxy) && !memcmp(data, a->directory, strlen(cast_const_char a->directory))) { skip_dir_check: - r = init_str(); + r = NULL; if (proxy) add_to_str(&r, &l, cast_uchar "Proxy-"); add_to_str(&r, &l, diff --git a/bfu.c b/bfu.c @@ -2178,7 +2178,7 @@ msg_box_fn(struct dialog_data *dlg) int w, rw; int y = 0; unsigned char **ptr; - unsigned char *text = init_str(); + unsigned char *text = NULL; int textl = 0; for (ptr = dlg->dlg->udata; *ptr; ptr++) add_to_str(&text, &textl, get_text_translation(*ptr, term)); diff --git a/bookmark.c b/bookmark.c @@ -695,7 +695,7 @@ convert_to_entity_string(unsigned char *str) unsigned char *dst, *p; int dstl; - dst = init_str(); + dst = NULL; dstl = 0; for (p = str; *p; p++) @@ -740,7 +740,7 @@ save_bookmarks(struct session *ses) if (!bookmark_ld.modified) return; - data = init_str(); + data = NULL; l = 0; add_to_str(&data, &l, cast_uchar "<HTML>\n" diff --git a/cache.c b/cache.c @@ -144,7 +144,7 @@ get_connection_cache_entry(struct connection *c) if (!*c->socks_proxy && !is_proxy_url(c->url) && c->last_lookup_state.addr.n) { unsigned char *a; - unsigned char *s = init_str(); + unsigned char *s = NULL; int l = 0; a = print_address(&c->last_lookup_state.addr .a[c->last_lookup_state.addr_index]); diff --git a/charsets.c b/charsets.c @@ -431,7 +431,7 @@ charset_upcase_string(unsigned char **chp, int cp) unsigned char * unicode_upcase_string(unsigned char *ch) { - unsigned char *r = init_str(); + unsigned char *r = NULL; unsigned int c; int rl = 0; for (;;) { diff --git a/connect.c b/connect.c @@ -272,7 +272,7 @@ handle_socks(void *c_) { struct connection *c = (struct connection *)c_; struct conn_info *b = c->newconn; - unsigned char *command = init_str(); + unsigned char *command = NULL; int len = 0; unsigned char *host; int wr; diff --git a/data.c b/data.c @@ -99,7 +99,7 @@ bad_url: } free(mime); - str = init_str(); + str = NULL; strl = 0; add_conv_str(&str, &strl, data, (int)strlen(cast_const_char data), -2); @@ -107,7 +107,7 @@ bad_url: if (!base64) { r = add_fragment(e, 0, str, strl); } else { - unsigned char *b64 = init_str(); + unsigned char *b64 = NULL; int b64l = 0; base64_decode(&b64, &b64l, str, strl); diff --git a/default.c b/default.c @@ -24,7 +24,7 @@ get_system_name(void) memset(&name, 0, sizeof name); EINTRLOOP(rs, uname(&name)); if (!rs) { - unsigned char *str = init_str(); + unsigned char *str = NULL; int l = 0; add_to_str(&str, &l, cast_uchar name.sysname); add_chr_to_str(&str, &l, ' '); @@ -109,7 +109,7 @@ get_token(unsigned char **line) while (**line == ' ' || **line == 9) (*line)++; if (**line) { - for (s = init_str(); **line; (*line)++) { + for (s = NULL; **line; (*line)++) { if (escape) escape = 0; else if (**line == '\\') { @@ -209,7 +209,7 @@ f: static unsigned char * create_config_string(struct option *options) { - unsigned char *s = init_str(); + unsigned char *s = NULL; int l = 0; int i; add_to_str(&s, &l, @@ -233,7 +233,7 @@ read_config_file(unsigned char *name) h = c_open(name, O_RDONLY | O_NOCTTY); if (h == -1) return NULL; - s = init_str(); + s = NULL; cfg_buffer = xmalloc(page_size); while ((r = hard_read(h, cfg_buffer, page_size)) > 0) { int i; @@ -262,7 +262,7 @@ write_to_config_file(unsigned char *name, unsigned char *c, int do_sync) int rs, err; try_new_count: tmp_namel = 0; - tmp_name = init_str(); + tmp_name = NULL; add_to_str(&tmp_name, &tmp_namel, name); for (w = tmp_namel - 1; w >= 0; w--) { if (dir_sep(tmp_name[w])) @@ -617,7 +617,7 @@ str_wr(struct option *o, unsigned char **s, int *l) { add_nm(o, s, l); if (strlen(cast_const_char o->ptr) + 1 > (size_t)o->max) { - unsigned char *s1 = init_str(); + unsigned char *s1 = NULL; int l1 = 0; add_bytes_to_str(&s1, &l1, o->ptr, o->max - 1); add_quoted_to_str(s, l, s1); @@ -997,7 +997,7 @@ gen_cmd(struct option *o, unsigned char ***argv, int *argc) unsigned char *r; if (!*argc) return cast_uchar "Parameter expected"; - e = init_str(); + e = NULL; l = 0; add_quoted_to_str(&e, &l, **argv); r = o->rd_cfg ? o->rd_cfg(o, e) : 0; @@ -1493,7 +1493,7 @@ save_url_history(void) return; history_file = stracpy(links_home); add_to_strn(&history_file, cast_uchar "links.his"); - hs = init_str(); + hs = NULL; hsl = 0; foreachback (struct history_item, hi, lhi, goto_url_history.items) { if (!*hi->str || hi->str[0] == ' ' diff --git a/file.c b/file.c @@ -214,7 +214,7 @@ get_filename(unsigned char *url) int ml; for (p = url + 7; *p && *p != POST_CHAR; p++) ; - m = init_str(); + m = NULL; ml = 0; add_conv_str(&m, &ml, url + 7, (int)(p - url - 7), -2); return m; @@ -325,7 +325,7 @@ dir: } last_uid = -1; last_gid = -1; - file = init_str(); + file = NULL; fl = 0; add_to_str(&file, &fl, cast_uchar "<html><head><title>"); flo = fl; @@ -360,7 +360,7 @@ dir: overalloc(); dir = xrealloc(dir, (dirl + 1) * sizeof(struct dirs)); dir[dirl].f = stracpy(cast_uchar de->d_name); - *(p = &dir[dirl++].s) = init_str(); + *(p = &dir[dirl++].s) = NULL; l = 0; n = stracpy(name); add_to_strn(&n, cast_uchar de->d_name); diff --git a/html.c b/html.c @@ -266,7 +266,7 @@ get_url_val(unsigned char *e, unsigned char *name) return a; need_convert: - c = init_str(); + c = NULL; l = 0; for (p = a; *p; p++) add_to_str(&c, &l, encode_utf_8(*p)); @@ -2132,7 +2132,7 @@ html_option(unsigned char *a) unsigned char *name; int namelen; int l = 0; - val = init_str(); + val = NULL; p = find_element_end(a); rrrr: while (p < eoff && WHITECHAR(*p)) @@ -2512,9 +2512,9 @@ abort: free(vx); } if (!v || !vx) { - lbl = init_str(); + lbl = NULL; lbl_l = 0; - vlbl = init_str(); + vlbl = NULL; vlbl_l = 0; nnmi = !!vx; } @@ -3661,7 +3661,7 @@ get_image_map(unsigned char *head, unsigned char *s, unsigned char *eof, struct menu_item *nm; int nmenu = 0; int i; - unsigned char *hd = init_str(); + unsigned char *hd = NULL; int hdl = 0; struct conv_table *ct; if (head) @@ -3718,7 +3718,7 @@ sp2: goto sp2; if (namelen == 1 && !casecmp(name, cast_uchar "A", 1)) { unsigned char *ss; - label = init_str(); + label = NULL; lblen = 0; se3: ss = s; @@ -3889,7 +3889,7 @@ scan_http_equiv(unsigned char *s, unsigned char *eof, unsigned char **head, if (pre_wrap) *pre_wrap = 0; if (title) - *title = init_str(); + *title = NULL; add_chr_to_str(head, hdl, '\n'); se: while (s < eof && *s != '<') diff --git a/html_r.c b/html_r.c @@ -633,7 +633,7 @@ html_tag(struct f_data *f, unsigned char *t, int x, int y) int ll; if (!f) return; - tt = init_str(); + tt = NULL; ll = 0; add_conv_str(&tt, &ll, t, (int)strlen(cast_const_char t), -2); sl = strlen(cast_const_char tt); @@ -1399,7 +1399,7 @@ really_format_html(struct cache_entry *ce, unsigned char *start, screen->use_tag = ce->count; startf = start; eofff = end; - head = init_str(); + head = NULL; hdl = 0; if (ce->head) add_to_str(&head, &hdl, ce->head); diff --git a/http.c b/http.c @@ -263,7 +263,7 @@ http_send_header(struct connection *c) && !casecmp(host, cast_uchar "https://", 8); if (c->ssl) proxy = 0; - hdr = init_str(); + hdr = NULL; if (!host) { http_bad_url: free(hdr); @@ -320,7 +320,7 @@ http_bad_url: if (parse_url(u, NULL, NULL, NULL, NULL, NULL, &u_host, &u_host_len, NULL, NULL, NULL, NULL, NULL)) goto http_bad_url; - u2 = init_str(); + u2 = NULL; add_bytes_to_str(&u2, &u2_len, u, u_host + u_host_len - u); add_to_str(&u2, &u2_len, proxies.dns_append); add_to_str(&u2, &u2_len, u_host + u_host_len); @@ -534,7 +534,7 @@ add_accept_charset(unsigned char **hdr, int *l, if (!accept_charset) { unsigned char *cs, *ac; int aclen = 0; - ac = init_str(); + ac = NULL; cs = get_cp_mime_name(0); if (aclen) add_chr_to_str(&ac, &aclen, ','); @@ -688,7 +688,7 @@ add_extra_options(unsigned char **hdr, int *l) unsigned char *new_hdr; int new_l; free(x); - new_hdr = init_str(); + new_hdr = NULL; new_l = 0; add_bytes_to_str(&new_hdr, &new_l, *hdr, v - *hdr); diff --git a/https.c b/https.c @@ -180,7 +180,7 @@ verify_ssl_certificate(links_ssl *ssl, unsigned char *host) int num = sk_X509_num(certs); int i; char *last_ca = NULL; - unsigned char *cas = init_str(); + unsigned char *cas = NULL; int casl = 0; for (i = num - 1; i >= 0; i--) { char space[3072]; @@ -249,7 +249,7 @@ unsigned char * get_cipher_string(links_ssl *ssl) { const char *version, *cipher; - unsigned char *s = init_str(); + unsigned char *s = NULL; int l = 0; add_num_to_str(&s, &l, SSL_get_cipher_bits(ssl->ssl, NULL)); diff --git a/links.h b/links.h @@ -255,15 +255,6 @@ int xstrcmp(const unsigned char *s1, const unsigned char *s2); void add_to_strn(unsigned char **s, unsigned char *a); void extend_str(unsigned char **s, int n); -static inline unsigned char * -init_str() -{ - unsigned char *p; - - p = mem_calloc(1L); - return p; -} - void add_bytes_to_str(unsigned char **s, int *l, unsigned char *a, size_t ll); void add_to_str(unsigned char **s, int *l, unsigned char *a); void add_chr_to_str(unsigned char **s, int *l, unsigned char a); diff --git a/memory.c b/memory.c @@ -54,7 +54,7 @@ free_all_caches(void) } } while (a & ST_SOMETHING_FREED); if (!(b & ST_CACHE_EMPTY)) { - unsigned char *m = init_str(); + unsigned char *m = NULL; int l = 0; foreach (struct cache_upcall, c, lc, cache_upcalls) if (!(c->upcall(SH_FREE_ALL) & ST_CACHE_EMPTY)) { diff --git a/menu.c b/menu.c @@ -54,7 +54,7 @@ menu_version(void *term_) maxlen = tl; } - s = init_str(); + s = NULL; l = 0; text_ptr = version_texts; @@ -310,7 +310,7 @@ resource_info(struct terminal *term, struct refresh *r2) r->fn = resource_info; r->timer = NULL; l = 0; - a = init_str(); + a = NULL; add_to_str(&a, &l, get_text_translation(TEXT_(T_RESOURCES), term)); add_to_str(&a, &l, cast_uchar ": "); @@ -2571,7 +2571,7 @@ query_file(struct session *ses, unsigned char *url, unsigned char *head, free(fc); check_filename(&file); - def = init_str(); + def = NULL; add_to_str(&def, &dfl, download_dir); if (*def && !dir_sep(def[strlen(cast_const_char def) - 1])) add_chr_to_str(&def, &dfl, '/'); diff --git a/session.c b/session.c @@ -218,7 +218,7 @@ static unsigned char * get_stat_msg(struct status *stat, struct terminal *term) { if (stat->state == S_TRANS && stat->prg->elapsed / 100) { - unsigned char *m = init_str(); + unsigned char *m = NULL; int l = 0; add_to_str(&m, &l, get_text_translation(TEXT_(T_RECEIVED), term)); @@ -410,7 +410,7 @@ unhx(unsigned char a) unsigned char * encode_url(unsigned char *url) { - unsigned char *u = init_str(); + unsigned char *u = NULL; int l = 0; add_to_str(&u, &l, cast_uchar "+++"); for (; *url; url++) { @@ -433,7 +433,7 @@ decode_url(unsigned char *url) if (casecmp(url, cast_uchar "+++", 3)) return stracpy(url); url += 3; - u = init_str(); + u = NULL; l = 0; for (; *url; url++) { if (*url != '+' || unhx(url[1]) == -1 || unhx(url[2]) == -1) @@ -626,7 +626,7 @@ download_percentage(struct download *down, int pad) struct status *stat = &down->stat; if (stat->state != S_TRANS || !test_percentage(stat)) return stracpy(cast_uchar ""); - s = init_str(); + s = NULL; l = 0; perc = download_meter(100, stat); if (pad) { @@ -655,7 +655,7 @@ download_window_function(struct dialog_data *dlg) down->win = dlg->win; if (stat->state == S_TRANS && stat->prg->elapsed / 100) { int l = 0; - m = init_str(); + m = NULL; t = 1; add_to_str(&m, &l, get_text_translation(TEXT_(T_RECEIVED), term)); @@ -1381,7 +1381,7 @@ get_temp_name(unsigned char *url, unsigned char *head) nm = cast_uchar tempnam(cast_const_char directory, "links"); if (!nm) return NULL; - name = init_str(); + name = NULL; nl = 0; add_to_str(&name, &nl, nm); free(nm); @@ -1403,7 +1403,7 @@ subst_file(unsigned char *prog, unsigned char *file, int cyg_subst) { unsigned char *orig_prog = prog; unsigned char *nn; - unsigned char *n = init_str(); + unsigned char *n = NULL; int l = 0; while (*prog) { int p; @@ -1539,7 +1539,7 @@ format_html(struct f_data_c *fd, struct object_request *rq, unsigned char *url, len = INT_MAX; f->uncacheable = 1; if (opt->plain == 2) { - start = init_str(); + start = NULL; stl = 0; add_to_str(&start, &stl, cast_uchar "<img src=\""); add_to_str(&start, &stl, f->rq->ce->url); @@ -3331,7 +3331,7 @@ create_session_info(int cp, unsigned char *url, unsigned char *framename, if (framename && !strcmp(cast_const_char framename, "_blank")) l1 = 0; - i = init_str(); + i = NULL; *ll = 0; add_bytes_to_str(&i, ll, (unsigned char *)&cp, sizeof(int)); add_bytes_to_str(&i, ll, (unsigned char *)&l, sizeof(int)); diff --git a/string.c b/string.c @@ -105,7 +105,11 @@ add_bytes_to_str(unsigned char **s, int *l, unsigned char *a, size_t ll) *l = *l + ll; - p = xreallocarray(p, *l, sizeof(unsigned char)); + /* FIXME: Hack, behaves like init_str() fn */ + if (ol == 0) + p = xreallocarray(p, *l + 1, sizeof(unsigned char)); + else + p = xreallocarray(p, *l, sizeof(unsigned char)); p[*l] = 0; memcpy(p + ol, a, ll); diff --git a/terminal.c b/terminal.c @@ -684,7 +684,7 @@ redraw_screen(struct terminal *term) struct term_spec *s; if (!term->dirty || (term->master && is_blocked())) return; - a = init_str(); + a = NULL; s = term->spec; for (y = 0; y < term->y; y++) { if (!memcmp(&term->screen[p], &term->last_screen[p], @@ -1047,7 +1047,7 @@ exec_on_terminal(struct terminal *term, unsigned char *path, rs, unlink(cast_const_char delet)); return; } - param = init_str(); + param = NULL; paraml = 0; add_chr_to_str(&param, &paraml, fg); add_to_str(&param, &paraml, path); @@ -1077,7 +1077,7 @@ exec_on_terminal(struct terminal *term, unsigned char *path, } else { unsigned char *data; int datal; - data = init_str(); + data = NULL; datal = 0; add_chr_to_str(&data, &datal, 0); add_chr_to_str(&data, &datal, fg); @@ -1095,7 +1095,7 @@ do_terminal_function(struct terminal *term, unsigned char code, { unsigned char *x_data; int x_datal; - x_data = init_str(); + x_data = NULL; x_datal = 0; add_chr_to_str(&x_data, &x_datal, code); add_to_str(&x_data, &x_datal, data); diff --git a/types.c b/types.c @@ -1114,7 +1114,7 @@ get_content_type_by_extension(unsigned char *url) if ((extl == 3 && !casecmp(ext, cast_uchar "tif", 3)) || (extl == 4 && !casecmp(ext, cast_uchar "tiff", 4))) return stracpy(cast_uchar "image/tiff"); - exxt = init_str(); + exxt = NULL; el = 0; add_to_str(&exxt, &el, cast_uchar "application/x-"); add_bytes_to_str(&exxt, &el, ext, extl); @@ -1447,7 +1447,7 @@ ret_x: } no_extended: - y = init_str(); + y = NULL; ly = 0; add_conv_str(&y, &ly, x, (int)strlen(cast_const_char x), -2); free(x); @@ -1483,7 +1483,7 @@ get_filename_from_url(unsigned char *url, unsigned char *head, int tmp) if (dir_sep(*e)) s = e + 1; ll = 0; - f = init_str(); + f = NULL; add_conv_str(&f, &ll, s, (int)(e - s), -2); if (!(ct = parse_http_header(head, cast_uchar "Content-Type", NULL))) goto no_ct; diff --git a/url.c b/url.c @@ -413,7 +413,7 @@ free_u_ret_up: data = get_url_data(u); if (!data) data = u; - r = init_str(); + r = NULL; rl = 0; add_bytes_to_str(&r, &rl, u, post_seq - u); q = strlen((char *)data); @@ -487,7 +487,7 @@ match: while (id[-1] != '/') id--; } - res = init_str(); + res = NULL; l = 0; add_to_str(&res, &l, cast_uchar patterns[i].result1); add_bytes_to_str(&res, &l, id, id_end - id); @@ -581,7 +581,7 @@ insert_wd(unsigned char **up, unsigned char *cwd) return; } free(host); - url = init_str(); + url = NULL; url_l = 0; add_bytes_to_str(&url, &url_l, u, 7); for (cw = cwd; *cw; cw++) { @@ -1040,7 +1040,7 @@ puny_encode(unsigned char *s, int len) if (uni_l > puny_max_length) goto err_free_uni; - res = init_str(); + res = NULL; res_l = 0; add_to_str(&res, &res_l, cast_uchar xn); @@ -1210,7 +1210,7 @@ puny_decode(unsigned char *s, int len) uni_l++; } - res = init_str(); + res = NULL; res_l = 0; for (i = 0; i < uni_l; i++) { @@ -1234,7 +1234,7 @@ idn_encode_host(unsigned char *host, int len, unsigned char *separator, { unsigned char *p, *s; int pl, l, i; - p = init_str(); + p = NULL; pl = 0; next_host_elem: @@ -1296,7 +1296,7 @@ idn_encode_url(unsigned char *url, int decode) if (!h) return NULL; - p = init_str(); + p = NULL; pl = 0; add_bytes_to_str(&p, &pl, url, host - url); add_to_str(&p, &pl, h); diff --git a/view.c b/view.c @@ -123,7 +123,7 @@ find_tag(struct f_data *f, unsigned char *name) struct list_head *ltag; unsigned char *tt; int ll; - tt = init_str(); + tt = NULL; ll = 0; add_conv_str(&tt, &ll, name, (int)strlen(cast_const_char name), -2); foreachback (struct tag, tag, ltag, f->tags) @@ -1315,7 +1315,7 @@ dump_to_file(struct f_data *fd, int h) for (i = 0; i < fd->nlinks; i++) { struct form_control *fc; struct link *lnk = &fd->links[i]; - unsigned char *s = init_str(); + unsigned char *s = NULL; int l = 0; add_num_to_str(&s, &l, i + 1); add_to_str(&s, &l, cast_uchar ". "); @@ -1712,7 +1712,7 @@ static unsigned char * encode_textarea(unsigned char *t) { int len = 0; - unsigned char *o = init_str(); + unsigned char *o = NULL; for (; *t; t++) { if (*t != '\n') add_chr_to_str(&o, &len, *t); @@ -1790,7 +1790,7 @@ fi_rep: } add_to_strn(&sub->name, fi ? cast_uchar ".x" : cast_uchar ".y"); - sub->value = init_str(); + sub->value = NULL; svl = 0; add_num_to_str(&sub->value, &svl, fi ? ismap_x : ismap_y); @@ -1879,7 +1879,7 @@ encode_controls(struct list_head *l, unsigned char **data, int *len, int lst = 0; unsigned char *p2; *len = 0; - *data = init_str(); + *data = NULL; foreach (struct submitted_value, sv, lsv, *l) { unsigned char *p = sv->value; if (lst) @@ -1917,7 +1917,7 @@ encode_multipart(struct session *ses, struct list_head *l, unsigned char **data, int rs; memset(bound, 'x', BL); *len = 0; - *data = init_str(); + *data = NULL; foreach (struct submitted_value, sv, lsv, *l) { unsigned char *ct; bnd: @@ -2133,7 +2133,7 @@ get_form_url(struct session *ses, struct f_data_c *f, struct form_control *form, } else { int l = 0; int i; - go = init_str(); + go = NULL; add_to_str(&go, &l, form->action); add_chr_to_str(&go, &l, POST_CHAR); if (form->method == FM_POST) @@ -2178,7 +2178,7 @@ get_link_url(struct session *ses, struct f_data_c *f, struct link *l, cast_const_char(l->where + strlen(cast_const_char l->where) - 4), "?0,0")) { - unsigned char *nu = init_str(); + unsigned char *nu = NULL; int ll = 0; add_bytes_to_str(&nu, &ll, l->where, strlen(cast_const_char l->where) - 3); @@ -3873,7 +3873,7 @@ send_open_in_new_xterm(struct terminal *term, void *open_window_, void *ses_) return; } - p = init_str(); + p = NULL; pl = 0; add_to_str(&p, &pl, cast_uchar "-base-session "); @@ -3908,7 +3908,7 @@ send_open_new_xterm(struct terminal *term, void *open_window_, void *ses_) *(int (*const *)(struct terminal *, unsigned char *, unsigned char *))open_window_; struct session *ses = ses_; - unsigned char *p = init_str(); + unsigned char *p = NULL; int pl = 0; unsigned char *path; add_to_str(&p, &pl, cast_uchar "-base-session "); @@ -4187,7 +4187,7 @@ print_current_titlex(struct f_data_c *fd, int w) if (!fd || !fd->vs || !fd->f_data) return NULL; w -= 1; - p = init_str(); + p = NULL; if (fd->yw < fd->f_data->y) { int pp, pe; if (fd->yw) { @@ -4215,10 +4215,13 @@ print_current_titlex(struct f_data_c *fd, int w) } if (!fd->f_data->title) return p; - m = init_str(); + m = NULL; add_to_str(&m, &ml, fd->f_data->title); mul = strlen((char *)m); - pul = strlen((char *)p); + if (p != NULL) + pul = strlen((char *)p); + else + pul = 0; if (mul + pul > w) { unsigned char *mm; if ((mul = w - pul) < 0) @@ -4227,7 +4230,8 @@ print_current_titlex(struct f_data_c *fd, int w) ; ml = (int)(mm - m); } - add_to_str(&m, &ml, p); + if (p != NULL) + add_to_str(&m, &ml, p); free(p); return m; } @@ -4248,7 +4252,7 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) l = &fd->f_data->links[fd->vs->current_link]; if (l->type == L_LINK) { if (!l->where && l->where_img) { - m = init_str(); + m = NULL; ll = 0; if (l->img_alt) { unsigned char *txt; @@ -4271,7 +4275,7 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) } if (l->where && strlen(cast_const_char l->where) >= 4 && !casecmp(l->where, cast_uchar "MAP@", 4)) { - m = init_str(); + m = NULL; ll = 0; add_to_str(&m, &ll, get_text_translation(TEXT_(T_USEMAP), term)); @@ -4292,7 +4296,7 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) return NULL; if (l->type == L_BUTTON) { if (l->form->type == FC_BUTTON) { - m = init_str(); + m = NULL; ll = 0; add_to_str(&m, &ll, get_text_translation(TEXT_(T_BUTTON), term)); @@ -4305,7 +4309,7 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) } if (!l->form->action) return NULL; - m = init_str(); + m = NULL; ll = 0; if (l->form->method == FM_GET) add_to_str(&m, &ll, @@ -4321,7 +4325,7 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) } if (l->type == L_CHECKBOX || l->type == L_SELECT || l->type == L_FIELD || l->type == L_AREA) { - m = init_str(); + m = NULL; ll = 0; switch (l->form->type) { case FC_RADIO: @@ -4360,7 +4364,6 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) term)); break; default: - free(m); return NULL; } if (l->form->name && l->form->name[0]) { @@ -4425,7 +4428,7 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) l = &fd->f_data->links[fd->vs->current_link]; if (l->type == L_LINK) { unsigned char *spc; - m = init_str(); + m = NULL; ll = 0; if (l->where && strlen(cast_const_char l->where) >= 4 && !casecmp(l->where, cast_uchar "MAP@", 4)) { @@ -4479,7 +4482,7 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) return NULL; if (l->type == L_BUTTON) { if (l->form->type == FC_BUTTON) { - m = init_str(); + m = NULL; ll = 0; add_to_str(&m, &ll, get_text_translation(TEXT_(T_BUTTON), term)); @@ -4492,7 +4495,7 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) } if (!l->form->action) return NULL; - m = init_str(); + m = NULL; ll = 0; if (l->form->method == FM_GET) add_to_str(&m, &ll, @@ -4508,7 +4511,7 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) } if (l->type == L_CHECKBOX || l->type == L_SELECT || l->type == L_FIELD || l->type == L_AREA) { - m = init_str(); + m = NULL; ll = 0; switch (l->form->type) { case FC_RADIO: @@ -4547,7 +4550,6 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) term)); break; default: - free(m); return NULL; } if (l->form->name && l->form->name[0]) { @@ -4615,7 +4617,7 @@ loc_msg(struct terminal *term, struct location *lo, struct f_data_c *frame) TEXT_(T_OK), msg_box_null, B_ENTER | B_ESC); return; } - s = init_str(); + s = NULL; add_to_str(&s, &l, get_text_translation(TEXT_(T_URL), term)); add_to_str(&s, &l, cast_uchar ": "); a = display_url(term, lo->url, 1);