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

Colomban Wendling notifications at xxxxx
Sun Jan 10 02:07:11 UTC 2016


> +	gint  numlines;         // number of lines in **lines array
> +	gchar *newfile;         // *final* string to replace current document
> +	gint  nfposn;           // keeps track of the position of newfile string
> +	gint  i;                // iterator
> +	gint  j;                // iterator
> +	gint  k;                // iterator
> +
> +	totalnumchars = sci_get_length(doc->editor->sci);
> +	totalnumlines = sci_get_line_count(doc->editor->sci);
> +	lines         = g_malloc(sizeof(gchar *) * totalnumlines);
> +	newfile       = g_malloc(sizeof(gchar) * (totalnumchars+1));
> +	numlines      = 0;
> +	nfposn        = 0;
> +	k             = 0;
> +
> +	if(newfile && lines)    // verify memory allocation

`g_malloc()` aborts on failure.  If you really mean to support allocation failure you need to use `g_try_malloc()` instead (no need unless you allocate really large data, as on very low memory situations something in GLib/GTK/Geany will most likely abort anyway).

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


More information about the Github-comments mailing list