Changes in uspace/lib/c/generic/sysinfo.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/sysinfo.c
r5a6cc679 ra35b458 73 73 * and transfer the keys as a single atomic operation. 74 74 */ 75 75 76 76 /* Get the keys size */ 77 77 errno_t ret = sysinfo_get_keys_size(path, size); … … 83 83 return NULL; 84 84 } 85 85 86 86 char *data = malloc(*size); 87 87 if (data == NULL) { … … 89 89 return NULL; 90 90 } 91 91 92 92 /* Get the data */ 93 93 size_t sz; … … 99 99 return data; 100 100 } 101 101 102 102 free(data); 103 103 *size = 0; … … 166 166 * and transfer the data as a single atomic operation. 167 167 */ 168 168 169 169 /* Get the binary data size */ 170 170 errno_t ret = sysinfo_get_data_size(path, size); … … 177 177 return NULL; 178 178 } 179 179 180 180 void *data = malloc(*size); 181 181 if (data == NULL) { … … 183 183 return NULL; 184 184 } 185 185 186 186 /* Get the data */ 187 187 size_t sz; … … 193 193 return data; 194 194 } 195 195 196 196 free(data); 197 197 *size = 0; … … 219 219 return NULL; 220 220 } 221 221 222 222 size_t pos = 0; 223 223 while (pos < total_size) { … … 226 226 if (((char *) data)[pos + cur_size] != 0) 227 227 break; 228 228 229 229 bool found = (str_cmp(data + pos, name) == 0); 230 230 231 231 pos += cur_size + 1; 232 232 if (pos >= total_size) 233 233 break; 234 234 235 235 /* Process value size */ 236 236 size_t value_size; 237 237 memcpy(&value_size, data + pos, sizeof(value_size)); 238 238 239 239 pos += sizeof(value_size); 240 240 if ((pos >= total_size) || (pos + value_size > total_size)) 241 241 break; 242 242 243 243 if (found) { 244 244 void *value = malloc(value_size); 245 245 if (value == NULL) 246 246 break; 247 247 248 248 memcpy(value, data + pos, value_size); 249 249 free(data); 250 250 251 251 *size = value_size; 252 252 return value; 253 253 } 254 254 255 255 pos += value_size; 256 256 } 257 257 258 258 free(data); 259 259 260 260 *size = 0; 261 261 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.