diff --git a/src/deviceInfo.c b/src/deviceInfo.c index 9a1d40e..7cb9580 100644 --- a/src/deviceInfo.c +++ b/src/deviceInfo.c @@ -81,7 +81,18 @@ nn_deviceInfo_t *nn_addDeviceInfo(nn_deviceInfoList_t *list, nn_address address, return list->info + i; } -void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *key); +void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *address) { + nn_size_t j = 0; + for(nn_size_t i = 0; i < list->len; i++) { + if(nn_strcmp(list->info[i].address, address) == 0) { + nn_deleteDeviceInfo(&list->ctx, &list->info[i]); + } else { + list->info[j] = list->info[i]; + j++; + } + } + list->len = j; +} nn_bool_t nn_registerDeviceKey(nn_deviceInfo_t *deviceInfo, const char *key, const char *value) { if(deviceInfo->len == deviceInfo->capacity) return false; diff --git a/src/emulator.c b/src/emulator.c index cfebd8f..c2a3321 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -820,6 +820,9 @@ int main(int argc, char **argv) { nn_registerDeviceKey(theRamStick, NN_DEVICEINFO_KEY_PRODUCT, "RAM 1:5"); nn_registerDeviceKey(theRamStick, NN_DEVICEINFO_KEY_VENDOR, "NeoComputers Technologies L.L.C."); + nn_addDeviceInfo(list, "test", 8); + nn_removeDeviceInfo(list, "test"); + nn_deviceInfo_t *theCPU = nn_addDeviceInfo(list, NULL, 8); nn_registerDeviceKey(theCPU, NN_DEVICEINFO_KEY_CLASS, NN_DEVICEINFO_CLASS_CPU); nn_registerDeviceKey(theCPU, NN_DEVICEINFO_KEY_DESCRIPTION, "Processor"); diff --git a/src/neonucleus.h b/src/neonucleus.h index d2e8b36..1058fbd 100644 --- a/src/neonucleus.h +++ b/src/neonucleus.h @@ -441,7 +441,7 @@ typedef struct nn_deviceInfo_t nn_deviceInfo_t; nn_deviceInfoList_t *nn_newDeviceInfoList(nn_Context *ctx, nn_size_t preallocate); void nn_deleteDeviceInfoList(nn_deviceInfoList_t *deviceInfoList); nn_deviceInfo_t *nn_addDeviceInfo(nn_deviceInfoList_t *list, nn_address address, nn_size_t maxKeys); -void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *key); +void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *address); nn_bool_t nn_registerDeviceKey(nn_deviceInfo_t *deviceInfo, const char *key, const char *value); nn_deviceInfo_t *nn_getDeviceInfoAt(nn_deviceInfoList_t *list, nn_size_t idx); nn_size_t nn_getDeviceCount(nn_deviceInfoList_t *list);