MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_values

Function parse_values

dpdk/app/test-bbdev/test_bbdev_vector.c:58–119  ·  view source on GitHub ↗

tokenization test values separated by a comma */

Source from the content-addressed store, hash-verified

56
57/* tokenization test values separated by a comma */
58static int
59parse_values(char *tokens, uint32_t **data, uint32_t *data_length)
60{
61 uint32_t n_tokens = 0;
62 uint32_t data_size = 32;
63
64 uint32_t *values, *values_resized;
65 char *tok, *error = NULL;
66
67 tok = strtok(tokens, VALUE_DELIMITER);
68 if (tok == NULL)
69 return -1;
70
71 values = (uint32_t *)
72 rte_zmalloc(NULL, sizeof(uint32_t) * data_size, 0);
73 if (values == NULL)
74 return -1;
75
76 while (tok != NULL) {
77 values_resized = NULL;
78
79 if (n_tokens >= data_size) {
80 data_size *= 2;
81
82 values_resized = (uint32_t *) rte_realloc(values,
83 sizeof(uint32_t) * data_size, 0);
84 if (values_resized == NULL) {
85 rte_free(values);
86 return -1;
87 }
88 values = values_resized;
89 }
90
91 values[n_tokens] = (uint32_t) strtoul(tok, &error, 0);
92
93 if ((error == NULL) || (*error != '\0')) {
94 printf("Failed with convert '%s'\n", tok);
95 rte_free(values);
96 return -1;
97 }
98
99 *data_length = *data_length + (strlen(tok) - strlen("0x"))/2;
100
101 tok = strtok(NULL, VALUE_DELIMITER);
102 if (tok == NULL)
103 break;
104
105 n_tokens++;
106 }
107
108 values_resized = (uint32_t *) rte_realloc(values,
109 sizeof(uint32_t) * (n_tokens + 1), 0);
110
111 if (values_resized == NULL) {
112 rte_free(values);
113 return -1;
114 }
115

Callers 1

parse_data_entryFunction · 0.70

Calls 6

strtokFunction · 0.85
rte_zmallocFunction · 0.85
rte_reallocFunction · 0.85
rte_freeFunction · 0.85
strtoulFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected