Signed-off-by: Nikola Pajkovsky npajkovs@redhat.com --- lib/Utils/Makefile.am | 3 +- lib/Utils/darray.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/Utils/darray.h | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 1 deletions(-) create mode 100644 lib/Utils/darray.c create mode 100644 lib/Utils/darray.h
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index 13144f6..172596b 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -26,7 +26,8 @@ libABRTUtils_la_SOURCES = \ ABRTException.cpp \ backtrace.h backtrace.c \ backtrace_parser.y \ - strbuf.h strbuf.c + strbuf.h strbuf.c \ + darray.h darray.c libABRTUtils_la_CPPFLAGS = \ -Wall -Werror \ -I$(srcdir)/../../inc \ diff --git a/lib/Utils/darray.c b/lib/Utils/darray.c new file mode 100644 index 0000000..0ff18a1 --- /dev/null +++ b/lib/Utils/darray.c @@ -0,0 +1,74 @@ +/* + Copyright (C) 2009 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <assert.h> + +#include "darray.h" + +#define SIZE 32 + +darray_t* darray_new() +{ + darray_t* da = (darray_t*)xmalloc(sizeof(darray_t)); + + da->size = SIZE; + da->last = 0; + da->data = (void**)xmalloc(da->size * sizeof(void**)); + int ii; + for (ii = 0; ii < da->size; ii++) + { + da->data[ii] = xmalloc(sizeof(void*)); + } + + return da; +} + +static void darray_grow(darray_t* da) +{ + da->size *= 2; + da->data = (void**)xrealloc(da->data, da->size * sizeof(void*)); +} + +void darray_add(darray_t* da, void* item) +{ + if (da->size == da->last) + { + darray_grow(da); + } + + da->data[da->last++] = item; + da->data[da->last] = NULL; +} + +int darray_empty(darray_t* da) +{ + return (da->last == 0 )? 1: 0; +} + +void darray_destroy(darray_t* da) +{ + if (!da) + return; + + int ii; + for (ii = 0; ii < da->size; ii++) + free(da->data[ii]); + + free(da->data); +} + diff --git a/lib/Utils/darray.h b/lib/Utils/darray.h new file mode 100644 index 0000000..1169e08 --- /dev/null +++ b/lib/Utils/darray.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2009 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef ABRT_DARRAY_H +#define ABRT_DARRAY_H + +#include <stdio.h> +#include <stdlib.h> +#include "xfuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _darray_t +{ + int size; + int last; + void** data; +} darray_t; + + +extern darray_t* darray_new(); + +extern void darray_add(darray_t* da, void* item); + +extern int darray_empty(darray_t* da); + +extern void darray_destroy(darray_t* da); + +#ifdef __cplusplus +} +#endif + +#endif
Signed-off-by: Nikola Pajkovsky npajkovs@redhat.com --- lib/Plugins/Bugzilla.cpp | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index bffccc1..c8544c6 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -118,7 +118,7 @@ struct ctx: public abrt_xmlrpc_conn { xmlrpc_int32 new_bug(const map_crash_data_t& pCrashData); int add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData); int get_bug_info(struct bug_info* bz, xmlrpc_int32 bug_id); - int add_comment(xmlrpc_int32 bug_id, const char* comment); + int add_comment(xmlrpc_int32 bug_id, const char* comment, bool is_private);
xmlrpc_value* call(const char* method, const char* format, ...); }; @@ -336,9 +336,11 @@ int ctx::add_plus_one_cc(xmlrpc_int32 bug_id, const char* login) return result ? 0 : -1; }
-int ctx::add_comment(xmlrpc_int32 bug_id, const char* comment) +int ctx::add_comment(xmlrpc_int32 bug_id, const char* comment, bool is_private) { - xmlrpc_value* result = call("Bug.update", "({s:i,s:{s:s}})", "ids", (int)bug_id, "updates", "comment", comment); + xmlrpc_value* result = call("Bug.add_comment", "({s:i,s:s,s:b})", "id", (int)bug_id, + "comment", comment, + "private", is_private); if (result) xmlrpc_DECREF(result); return result ? 0 : -1; @@ -757,7 +759,9 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, );
update_client(_("Add new comment into bug(%d)"), (int)bug_id); - if (bz_server.add_comment(bug_id, description.c_str()) == -1) + + // gui is not ready, default do not make it private + if (bz_server.add_comment(bug_id, description.c_str(), false) == -1) { bug_info_destroy(&bz); throw_if_xml_fault_occurred(&bz_server.env);
On Wed, 14 Apr 2010 15:35:33 +0200, Nikola Pajkovsky wrote:
+darray_t* darray_new()
darray.c:26: warning: function declaration isn’t a prototype
+void darray_add(darray_t* da, void* item) +{
- if (da->size == da->last)
- {
darray_grow(da);
- }
- da->data[da->last++] = item;
- da->data[da->last] = NULL;
+}
==6022== Invalid write of size 8 ==6022== at 0x4006E5: darray_add (darray.c:55) ==6022== Address 0x4c32190 is 0 bytes after a block of size 256 alloc'd ==6022== at 0x4A0515D: malloc (vg_replace_malloc.c:195) ==6022== by 0x4005D7: darray_new (darray.c:31)
+void darray_destroy(darray_t* da) +{
- if (!da)
return;
- int ii;
- for (ii = 0; ii < da->size; ii++)
free(da->data[ii]);
- free(da->data);
+}
darray_destroy leaks the `sizeof (darray_t)' memory of `da' itself.
+#include <stdio.h> +#include <stdlib.h> +#include "xfuncs.h"
These include files are required by "darray.c", not by "darray.h".
+extern darray_t* darray_new();
darray.h:38: warning: function declaration isn’t a prototype
Regards, Jan
crash-catcher@lists.fedorahosted.org