libstats: add append API to libstats
PATCH 1/3 libstats: add append API to libstats
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.
testcases/realtime/include/libstats.h +8 -0
@@ -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 */
testcases/realtime/lib/libstats.c +16 -0
@@ -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 <unistd.h> #include <math.h> #include <libstats.h> +#include <librttest.h> int save_stats =0 ;
@@ -62,12 +64,26 @@ static int stats_record_compare(const voint 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));
Signature · 13 lines
Thanks, Kiran ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 5 lines · Kiran
This patch adds a new API
stats_container_appendto libstats. This function adds a newstats_record_tto the records list instats_container_t.Signed-off-by Kiran Prakash <[email protected]>
Thanks.
Regards--
Subrata
Quoted 64 lines
Acked-by Gowrishankar <[email protected]>Acked-by Darren Hart <[email protected]>Acked-by Sripathi Kodi <[email protected]>diff -upr
ltp-full-20090531_orig/testcases/realtime/include/libstats.hltp-full-20090531/testcases/realtime/include/libstats.htestcases/realtime/include/libstats.h +8
-0@@ -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.cltp-full-20090531/testcases/realtime/lib/libstats.ctestcases/realtime/lib/libstats.c +9
-0@@ -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 <unistd.h> #include <math.h> #include <libstats.h> +#include <librttest.h> int save_stats =0 ;@@ -62,12 +64,26 @@ static int stats_record_compare(const voint 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);
testcases/realtime/lib/libstats.c static int stats_record_compare(const vo · line 89
Quoted 10 lines
testcases/realtime/lib/libstats.c +7
-0+ 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list