comm.c (1341f3e4c0276aae3de6d902c9202265d89fe438) comm.c (3178f58b989430fd0721df97bf21cf1c0e8cc419)
1#include "comm.h"
2#include "util.h"
3#include <stdlib.h>
4#include <stdio.h>
5
6struct comm_str {
7 char *str;
8 struct rb_node rb_node;

--- 80 unchanged lines hidden (view full) ---

89 return NULL;
90 }
91
92 comm_str__get(comm->comm_str);
93
94 return comm;
95}
96
1#include "comm.h"
2#include "util.h"
3#include <stdlib.h>
4#include <stdio.h>
5
6struct comm_str {
7 char *str;
8 struct rb_node rb_node;

--- 80 unchanged lines hidden (view full) ---

89 return NULL;
90 }
91
92 comm_str__get(comm->comm_str);
93
94 return comm;
95}
96
97void comm__override(struct comm *comm, const char *str, u64 timestamp)
97int comm__override(struct comm *comm, const char *str, u64 timestamp)
98{
98{
99 struct comm_str *old = comm->comm_str;
99 struct comm_str *new, *old = comm->comm_str;
100
100
101 comm->comm_str = comm_str__findnew(str, &comm_str_root);
102 if (!comm->comm_str) {
103 comm->comm_str = old;
104 return;
105 }
101 new = comm_str__findnew(str, &comm_str_root);
102 if (!new)
103 return -ENOMEM;
106
104
107 comm->start = timestamp;
108 comm_str__get(comm->comm_str);
105 comm_str__get(new);
109 comm_str__put(old);
106 comm_str__put(old);
107 comm->comm_str = new;
108 comm->start = timestamp;
109
110 return 0;
110}
111
112void comm__free(struct comm *comm)
113{
114 comm_str__put(comm->comm_str);
115 free(comm);
116}
117
118const char *comm__str(const struct comm *comm)
119{
120 return comm->comm_str->str;
121}
111}
112
113void comm__free(struct comm *comm)
114{
115 comm_str__put(comm->comm_str);
116 free(comm);
117}
118
119const char *comm__str(const struct comm *comm)
120{
121 return comm->comm_str->str;
122}