MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_sizedstring_parse

Function ng_sizedstring_parse

freebsd/netgraph/ng_parse.c:884–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882 ************************************************************************/
883
884static int
885ng_sizedstring_parse(const struct ng_parse_type *type,
886 const char *s, int *off, const u_char *const start,
887 u_char *const buf, int *buflen)
888{
889 char *sval;
890 int len;
891 int slen;
892
893 if ((sval = ng_get_string_token(s, off, &len, &slen)) == NULL)
894 return (EINVAL);
895 if (slen > USHRT_MAX) {
896 free(sval, M_NETGRAPH_PARSE);
897 return (EINVAL);
898 }
899 *off += len;
900 *((u_int16_t *)buf) = (u_int16_t)slen;
901 bcopy(sval, buf + 2, slen);
902 free(sval, M_NETGRAPH_PARSE);
903 *buflen = 2 + slen;
904 return (0);
905}
906
907static int
908ng_sizedstring_unparse(const struct ng_parse_type *type,

Callers

nothing calls this directly

Calls 2

ng_get_string_tokenFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected