[Github-comments] [geany-plugins] Add new "Lineoperations" plugin (#324)

Colomban Wendling notifications at xxxxx
Sun Jan 17 14:28:47 UTC 2016


> +
> +	sci_end_undo_action(doc->editor->sci);
> +}
> +
> +
> +/* Sort Lines Ascending and Descending */
> +void sortlines(GeanyDocument *doc, gboolean asc) {
> +	gint  total_num_chars;  /* number of characters in the document */
> +	gint  total_num_lines;  /* number of lines in the document */
> +	gchar **lines;          /* array to hold all lines in the document */
> +	gchar *new_file;        /* *final* string to replace current document */
> +	gint  i;                /* iterator */
> +
> +	total_num_chars = sci_get_length(doc->editor->sci);
> +	total_num_lines = sci_get_line_count(doc->editor->sci);
> +	lines           = g_malloc(sizeof(gchar *) * total_num_lines+1);

there's a subtle bug here: the +1 is not applied correctly as `*` has priority over `+`.  Wrap in parentheses. (thanks to Valgrind for finding this)

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/324/files#r49946955
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160117/39bc1e89/attachment.html>


More information about the Github-comments mailing list