- int i;
-
- num_entries = 0;
- entries = NULL;
-
- dict_apply_to_all(dict_opt_c, fill_struct, NULL);
-
- qsort(entries, num_entries, sizeof(*entries), compar);
-
- fprintf(options.output, "%% time seconds usecs/call calls function\n");
- fprintf(options.output, "------ ----------- ----------- --------- --------------------\n");
- for (i = 0; i < num_entries; i++) {
- unsigned long long int c;
- unsigned long long int p;
- c = 1000000 * (int)entries[i].tv.tv_sec +
- (int)entries[i].tv.tv_usec;
- p = 100000 * c / tot_usecs + 5;
- fprintf(options.output, "%3lu.%02lu %4d.%06d %11lu %9d %s\n",
- (unsigned long int)(p / 1000),
- (unsigned long int)((p / 10) % 100),
- (int)entries[i].tv.tv_sec, (int)entries[i].tv.tv_usec,
- (unsigned long int)(c / entries[i].count),
- entries[i].count,
-#ifdef USE_DEMANGLE
- options.demangle ? my_demangle(entries[i].name) :
-#endif
- entries[i].name);
+ free((char *)*stringp);
+}
+
+void
+summary_account_call(struct library_symbol *libsym, struct timedelta spent)
+{
+ assert(options.summary);
+
+ if (dict_opt_c == NULL) {
+ dict_opt_c = malloc(sizeof(*dict_opt_c));
+ if (dict_opt_c == NULL) {
+ oom:
+ fprintf(stderr,
+ "Can't allocate memory for "
+ "keeping track of -c.\n");
+ free(dict_opt_c);
+ options.summary = 0;
+ return;
+ }
+ DICT_INIT(dict_opt_c, char *, struct opt_c_struct,
+ dict_hash_string, dict_eq_string, NULL);
+ }
+
+ struct opt_c_struct *st = DICT_FIND_REF(dict_opt_c, &libsym->name,
+ struct opt_c_struct);
+ if (st == NULL) {
+ const char *na = strdup(libsym->name);
+ struct opt_c_struct new_st = {.count = 0, .tv = {0, 0}};
+ if (na == NULL
+ || DICT_INSERT(dict_opt_c, &na, &new_st) < 0) {
+ free((char *) na);
+ DICT_DESTROY(dict_opt_c, const char *,
+ struct opt_c_struct,
+ free_stringp_cb, NULL, NULL);
+ goto oom;
+ }
+ st = DICT_FIND_REF(dict_opt_c, &libsym->name,
+ struct opt_c_struct);
+ assert(st != NULL);
+ }
+
+ if (st->tv.tv_usec + spent.tm.tv_usec > 1000000) {
+ st->tv.tv_usec += spent.tm.tv_usec - 1000000;
+ st->tv.tv_sec++;
+ } else {
+ st->tv.tv_usec += spent.tm.tv_usec;