Skip to content

Commit

Permalink
msgbuf: add tag stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
RaitoBezarius committed Jul 19, 2022
1 parent 6cf5c7a commit 573a074
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/msgbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,16 @@ msgbuf_append_tag(struct MsgBuf *msgbuf, const char *key, const char *value, uns
}
}

static inline void
msgbuf_strip_tag(struct MsgBuf *msgbuf, const char *key) {
// Replace the latest tag by this one.
for (unsigned int tag_index = 0; tag_index < msgbuf->n_tags ; tag_index++) {
if (msgbuf->tags[tag_index].key == key) {
msgbuf->tags[tag_index] = msgbuf->tags[msgbuf->n_tags - 1];
break;
}
}
msgbuf->n_tags--;
}

#endif

0 comments on commit 573a074

Please sign in to comment.