Return-Path: Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.122] helo=mx.sourceforge.net) by h25xhf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MXvbC-0007f3-Gv for ltp-list@lists.sourceforge.net; Mon, 03 Aug 2009 11:21:02 +0000 Received: from e3.ny.us.ibm.com ([32.97.182.143]) by 72vjzd1.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1MXvb5-00016g-Gz for ltp-list@lists.sourceforge.net; Mon, 03 Aug 2009 11:21:02 +0000 From: Subrata Modak In-Reply-To: <1249044148.5432.72.camel@kiran-laptop> References: <1249044148.5432.72.camel@kiran-laptop> Date: Mon, 03 Aug 2009 16:50:41 +0530 Message-Id: <1249298442.7460.31.camel@subratamodak.linux.ibm.com> Mime-Version: 1.0 Subject: Re: [LTP] [PATCH 1/3] libstats: add append API to libstats Reply-To: subrata@linux.vnet.ibm.com List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: Kiran Cc: gowrishankar.m@in.ibm.com, ltp-list On Fri, 2009-07-31 at 18:12 +0530, Kiran wrote: > This patch adds a new API stats_container_append to libstats. This > function adds a new stats_record_t to the records list in > stats_container_t. > > Signed-off-by: Kiran Prakash Thanks. Regards-- Subrata > Acked-by: Gowrishankar > Acked-by: Darren Hart > Acked-by: Sripathi Kodi > > diff -upr ltp-full-20090531_orig/testcases/realtime/include/libstats.h ltp-full-20090531/testcases/realtime/include/libstats.h > --- ltp-full-20090531_orig/testcases/realtime/include/libstats.h 2008-04-20 22:50:18.000000000 +0530 > +++ ltp-full-20090531/testcases/realtime/include/libstats.h 2009-07-24 18:39:11.000000000 +0530 > @@ -56,6 +56,7 @@ typedef struct stats_record { > > typedef struct stats_container { > long size; > + long index; > stats_record_t *records; > } stats_container_t; > > @@ -162,4 +163,11 @@ void stats_hist_print(stats_container_t > */ > int stats_container_save(char *filename, char *title, char *labelx, char *labely, stats_container_t *data, char *mode); > > +/* stats_container_append - appends stats_record_t to data > + * data: stats_container_t structure for holding the records list, index of > + * min and max elements in records list and the sum > + * rec: stats_record_t to be appended to the records list in data > + * Returns the index of the appended record on success and -1 on error > + */ > +int stats_container_append(stats_container_t *data, stats_record_t rec); > #endif /* LIBSTAT_H */ > diff -upr ltp-full-20090531_orig/testcases/realtime/lib/libstats.c ltp-full-20090531/testcases/realtime/lib/libstats.c > --- ltp-full-20090531_orig/testcases/realtime/lib/libstats.c 2008-04-20 22:50:18.000000000 +0530 > +++ ltp-full-20090531/testcases/realtime/lib/libstats.c 2009-07-25 21:10:06.000000000 +0530 > @@ -31,6 +31,7 @@ > * > * HISTORY > * 2006-Oct-17: Initial version by Darren Hart > + * 2009-Jul-22: Addition of stats_container_append function by Kiran Prakash > * > * TODO: the save routine for gnuplot plotting should be more modular... > * > @@ -43,6 +44,7 @@ > #include > #include > #include > +#include > > int save_stats = 0; > > @@ -62,12 +64,26 @@ static int stats_record_compare(const vo > int stats_container_init(stats_container_t *data, long size) > { > data->size = size; > + data->index = -1; > data->records = calloc(size, sizeof(stats_record_t)); > if (!data->records) > return -1; > return 0; > } > > +int stats_container_append(stats_container_t *data, stats_record_t rec) > +{ > + int myindex = ++data->index; > + if (myindex >= data->size) { > + debug(DBG_ERR, "Number of elements cannot be more than %d\n", > + data->size); > + data->index--; > + return -1; > + } > + data->records[myindex] = rec; > + return myindex; > +} > + > int stats_container_resize(stats_container_t *data, long size) > { > stats_record_t *newrecords = realloc(data->records, size*sizeof(stats_record_t)); > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list