MCPcopy Create free account
hub / github.com/apache/trafficserver / RecDataSet

Function RecDataSet

src/records/RecUtils.cc:118–168  ·  view source on GitHub ↗

------------------------------------------------------------------------- RecDataSet -------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

116// RecDataSet
117//-------------------------------------------------------------------------
118bool
119RecDataSet(RecDataT data_type, RecData *data_dst, RecData *data_src)
120{
121 bool rec_set = false;
122
123 switch (data_type) {
124 case RECD_STRING:
125 if (data_src->rec_string == nullptr) {
126 if (data_dst->rec_string != nullptr) {
127 ats_free(data_dst->rec_string);
128 data_dst->rec_string = nullptr;
129 rec_set = true;
130 }
131 } else if (((data_dst->rec_string) && (strcmp(data_dst->rec_string, data_src->rec_string) != 0)) ||
132 ((data_dst->rec_string == nullptr) && (data_src->rec_string != nullptr))) {
133 ats_free(data_dst->rec_string);
134
135 data_dst->rec_string = ats_strdup(data_src->rec_string);
136 rec_set = true;
137 // Chop trailing spaces
138 char *end = data_dst->rec_string + strlen(data_dst->rec_string) - 1;
139
140 while (end >= data_dst->rec_string && isspace(*end)) {
141 end--;
142 }
143 *(end + 1) = '\0';
144 }
145 break;
146 case RECD_INT:
147 if (data_dst->rec_int != data_src->rec_int) {
148 data_dst->rec_int = data_src->rec_int;
149 rec_set = true;
150 }
151 break;
152 case RECD_FLOAT:
153 if (data_dst->rec_float != data_src->rec_float) {
154 data_dst->rec_float = data_src->rec_float;
155 rec_set = true;
156 }
157 break;
158 case RECD_COUNTER:
159 if (data_dst->rec_counter != data_src->rec_counter) {
160 data_dst->rec_counter = data_src->rec_counter;
161 rec_set = true;
162 }
163 break;
164 default:
165 ink_assert(!"Wrong RECD type!");
166 }
167 return rec_set;
168}
169
170int
171RecDataCmp(RecDataT type, RecData left, RecData right)

Callers 8

RecDataSetFromInt64Function · 0.85
RecDataSetFromFloatFunction · 0.85
RecDataSetFromStringFunction · 0.85
register_recordFunction · 0.85
RecRegisterStatFunction · 0.85
RecGetRecord_XmallocFunction · 0.85
RecForceInsertFunction · 0.85
RecSetRecordFunction · 0.85

Calls 2

ats_freeFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected