Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/sysinfo.c

    r5a6cc679 ra35b458  
    7373         * and transfer the keys as a single atomic operation.
    7474         */
    75        
     75
    7676        /* Get the keys size */
    7777        errno_t ret = sysinfo_get_keys_size(path, size);
     
    8383                return NULL;
    8484        }
    85        
     85
    8686        char *data = malloc(*size);
    8787        if (data == NULL) {
     
    8989                return NULL;
    9090        }
    91        
     91
    9292        /* Get the data */
    9393        size_t sz;
     
    9999                return data;
    100100        }
    101        
     101
    102102        free(data);
    103103        *size = 0;
     
    166166         * and transfer the data as a single atomic operation.
    167167         */
    168        
     168
    169169        /* Get the binary data size */
    170170        errno_t ret = sysinfo_get_data_size(path, size);
     
    177177                return NULL;
    178178        }
    179        
     179
    180180        void *data = malloc(*size);
    181181        if (data == NULL) {
     
    183183                return NULL;
    184184        }
    185        
     185
    186186        /* Get the data */
    187187        size_t sz;
     
    193193                return data;
    194194        }
    195        
     195
    196196        free(data);
    197197        *size = 0;
     
    219219                return NULL;
    220220        }
    221        
     221
    222222        size_t pos = 0;
    223223        while (pos < total_size) {
     
    226226                if (((char *) data)[pos + cur_size] != 0)
    227227                        break;
    228                
     228
    229229                bool found = (str_cmp(data + pos, name) == 0);
    230                
     230
    231231                pos += cur_size + 1;
    232232                if (pos >= total_size)
    233233                        break;
    234                
     234
    235235                /* Process value size */
    236236                size_t value_size;
    237237                memcpy(&value_size, data + pos, sizeof(value_size));
    238                
     238
    239239                pos += sizeof(value_size);
    240240                if ((pos >= total_size) || (pos + value_size > total_size))
    241241                        break;
    242                
     242
    243243                if (found) {
    244244                        void *value = malloc(value_size);
    245245                        if (value == NULL)
    246246                                break;
    247                        
     247
    248248                        memcpy(value, data + pos, value_size);
    249249                        free(data);
    250                        
     250
    251251                        *size = value_size;
    252252                        return value;
    253253                }
    254                
     254
    255255                pos += value_size;
    256256        }
    257        
     257
    258258        free(data);
    259        
     259
    260260        *size = 0;
    261261        return NULL;
Note: See TracChangeset for help on using the changeset viewer.