From 83346830688525a287489cc791299cbc945d4fc4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 2 Jan 2005 03:58:21 +0000 Subject: [project @ 2005-01-02 03:58:20 by jmb] xcalloc/xrealloc/xstrdup-purge - Lose remaining calls (and purge the relevant functions from utils.c) svn path=/import/netsurf/; revision=1419 --- riscos/401login.c | 6 +++--- riscos/font.c | 27 +++++++++++++++++++++++---- riscos/plotters.c | 3 +-- riscos/uri.c | 47 +++++++++++++++++++++++------------------------ 4 files changed, 50 insertions(+), 33 deletions(-) (limited to 'riscos') diff --git a/riscos/401login.c b/riscos/401login.c index 145ad63f8..4f68d463d 100644 --- a/riscos/401login.c +++ b/riscos/401login.c @@ -57,7 +57,7 @@ void gui_401login_open(struct browser_window *bw, struct content *c, char *realm ro_gui_401login_open(bw->window->window, host, realm, murl); - xfree(host); + free(host); } @@ -134,8 +134,8 @@ void get_unamepwd(void) { char *lidets = calloc(strlen(uname)+strlen(pwd)+2, sizeof(char)); if (!lidets) { - LOG(("Insufficient memory for calloc")); - warn_user("NoMemory", 0); + LOG(("Insufficient memory for calloc")); + warn_user("NoMemory", 0); return; } diff --git a/riscos/font.c b/riscos/font.c index 924559e71..0aaff3b87 100644 --- a/riscos/font.c +++ b/riscos/font.c @@ -394,6 +394,9 @@ unsigned long nsfont_width(struct font_data *font, const char *text, break; case FONTTYPE_STANDARD_LATIN1: { const char *loc_text = cnv_strn_local_enc(text, length, NULL); + if (!loc_text) + return 0; + error = xfont_scan_string((font_f)font->handle, loc_text, font_GIVEN_FONT @@ -430,8 +433,9 @@ unsigned long nsfont_width(struct font_data *font, const char *text, * \param x horizontal position in pixels * \param char_offset updated to give the offset in the string * \param pixel_offset updated to give the coordinate of the character in pixels + * \return true on success, false on failure. */ -void nsfont_position_in_string(struct font_data *font, const char *text, +bool nsfont_position_in_string(struct font_data *font, const char *text, size_t length, unsigned long x, int *char_offset, int *pixel_offset) { @@ -475,6 +479,9 @@ void nsfont_position_in_string(struct font_data *font, const char *text, case FONTTYPE_STANDARD_LATIN1: { const ptrdiff_t *back_mapP; const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP); + if (!loc_text) + return false; + error = xfont_scan_string((font_f)font->handle, loc_text, font_GIVEN_BLOCK @@ -495,11 +502,14 @@ void nsfont_position_in_string(struct font_data *font, const char *text, } if (error != NULL) { LOG(("(u)font_scan_string failed : %s\n", error->errmess)); - die("nsfont_position_in_string: (u)font_scan_string failed"); +/* die("nsfont_position_in_string: (u)font_scan_string failed");*/ + return false; } *char_offset = (int)(split - text); *pixel_offset = x_out / 800; + + return true; } @@ -559,6 +569,9 @@ char *nsfont_split(struct font_data *font, const char *text, case FONTTYPE_STANDARD_LATIN1: { const ptrdiff_t *back_mapP; const char *loc_text = cnv_strn_local_enc(text, length, &back_mapP); + if (!loc_text) + return NULL; + error = xfont_scan_string((font_f)font->handle, loc_text, font_GIVEN_BLOCK @@ -591,7 +604,7 @@ char *nsfont_split(struct font_data *font, const char *text, } -void nsfont_paint(struct font_data *data, const char *text, +bool nsfont_paint(struct font_data *data, const char *text, size_t length, int xpos, int ypos, void *trfm) { os_error *error; @@ -648,6 +661,9 @@ void nsfont_paint(struct font_data *data, const char *text, break; case FONTTYPE_STANDARD_LATIN1: { const char *loc_text = cnv_strn_local_enc(text, length, NULL); + if (!loc_text) + return false; + error = xfont_paint((font_f)data->handle, loc_text, flags, xpos, ypos, NULL, trfm, 0); @@ -660,8 +676,11 @@ void nsfont_paint(struct font_data *data, const char *text, } if (error != NULL) { LOG(("(u)font_paint failed : %s\n", error->errmess)); - die("nsfont_paint: (u)font_paint failed"); + /*die("nsfont_paint: (u)font_paint failed");*/ + return false; } + + return true; } diff --git a/riscos/plotters.c b/riscos/plotters.c index 12c4b7816..7fea7affc 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -312,11 +312,10 @@ bool ro_plot_text(int x, int y, struct font_data *font, error->errnum, error->errmess)); return false; } - nsfont_paint(font, text, length, + return nsfont_paint(font, text, length, ro_plot_origin_x + x * 2, ro_plot_origin_y - y * 2, &ro_plot_trfm); - return true; } diff --git a/riscos/uri.c b/riscos/uri.c index 04edc208f..4c0790398 100644 --- a/riscos/uri.c +++ b/riscos/uri.c @@ -32,43 +32,42 @@ extern wimp_t task_handle; void ro_uri_message_received(uri_full_message_process* uri_message) { - uri_h uri_handle; - char* uri_requested; - int uri_length; + uri_h uri_handle; + char* uri_requested; + int uri_length; - uri_handle = uri_message->handle; + uri_handle = uri_message->handle; - if (!fetch_can_fetch(uri_message->uri)) return; + if (!fetch_can_fetch(uri_message->uri)) return; - uri_message->your_ref = uri_message->my_ref; - uri_message->action = message_URI_PROCESS_ACK; + uri_message->your_ref = uri_message->my_ref; + uri_message->action = message_URI_PROCESS_ACK; - xwimp_send_message(wimp_USER_MESSAGE, - (wimp_message*)uri_message, - uri_message->sender); + xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)uri_message, + uri_message->sender); - xuri_request_uri(0, 0, 0, uri_handle, &uri_length); - uri_requested = calloc((unsigned int)uri_length, sizeof(char)); + xuri_request_uri(0, 0, 0, uri_handle, &uri_length); + uri_requested = calloc((unsigned int)uri_length, sizeof(char)); - if (uri_requested == NULL) - return; + if (uri_requested == NULL) + return; - xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL); + xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL); - browser_window_create(uri_requested, NULL, 0); + browser_window_create(uri_requested, NULL, 0); - xfree(uri_requested); + free(uri_requested); } -bool ro_uri_launch(char *uri) { - +bool ro_uri_launch(char *uri) +{ uri_h uri_handle; wimp_t handle_task; uri_dispatch_flags returned; os_error *e; e = xuri_dispatch(uri_DISPATCH_INFORM_CALLER, uri, task_handle, - &returned, &handle_task, &uri_handle); + &returned, &handle_task, &uri_handle); if (e || returned & 1) { return false; @@ -77,8 +76,8 @@ bool ro_uri_launch(char *uri) { return true; } -void ro_uri_bounce(uri_full_message_return_result *message) { - +void ro_uri_bounce(uri_full_message_return_result *message) +{ char uri_buf[512]; os_error *e; @@ -87,8 +86,8 @@ void ro_uri_bounce(uri_full_message_return_result *message) { e = xuri_request_uri(0, uri_buf, sizeof uri_buf, message->handle, 0); if (e) { - LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess)); - return; + LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess)); + return; } ro_url_load(uri_buf); -- cgit v1.2.3