Global: major FFlist related code refactor

This commit is contained in:
李通洲
2023-04-21 22:41:32 +08:00
parent 6d002c175f
commit 39582471e8
14 changed files with 43 additions and 37 deletions
+1 -4
View File
@@ -37,8 +37,7 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options)
return;
}
FFlist filtered;
ffListInit(&filtered, sizeof(FFBluetoothDevice*));
FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFBluetoothDevice*));
FF_LIST_FOR_EACH(FFBluetoothDevice, device, bluetooth->devices)
{
@@ -59,8 +58,6 @@ void ffPrintBluetooth(FFinstance* instance, FFBluetoothOptions* options)
uint8_t index = (uint8_t) (filtered.length == 1 ? 0 : i + 1);
printDevice(instance, options, *(FFBluetoothDevice**)ffListGet(&filtered, i), index);
}
ffListDestroy(&filtered);
}
void ffInitBluetoothOptions(FFBluetoothOptions* options)
+2 -2
View File
@@ -7,8 +7,8 @@
void ffPrintBrightness(FFinstance* instance, FFBrightnessOptions* options)
{
FF_LIST_AUTO_DESTROY result;
ffListInit(&result, sizeof(FFBrightnessResult));
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult));
const char* error = ffDetectBrightness(&result);
if(error)
+2 -2
View File
@@ -22,8 +22,8 @@ static void printDevice(FFinstance* instance, FFGamepadOptions* options, const F
void ffPrintGamepad(FFinstance* instance, FFGamepadOptions* options)
{
FF_LIST_AUTO_DESTROY result;
ffListInit(&result, sizeof(FFGamepadDevice));
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFGamepadDevice));
const char* error = ffDetectGamepad(instance, &result);
if(error)
+1 -2
View File
@@ -55,8 +55,7 @@ static void printIp(FFLocalIpResult* ip)
void ffPrintLocalIp(FFinstance* instance, FFLocalIpOptions* options)
{
FF_LIST_AUTO_DESTROY results;
ffListInit(&results, sizeof(FFLocalIpResult));
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult));
const char* error = ffDetectLocalIps(options, &results);
+3 -4
View File
@@ -37,8 +37,8 @@ static void printDevice(FFinstance* instance, FFSoundOptions* options, const FFS
void ffPrintSound(FFinstance* instance, FFSoundOptions* options)
{
FF_LIST_AUTO_DESTROY result;
ffListInit(&result, sizeof(FFSoundDevice));
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSoundDevice));
const char* error = ffDetectSound(instance, &result);
if(error)
@@ -47,8 +47,7 @@ void ffPrintSound(FFinstance* instance, FFSoundOptions* options)
return;
}
FF_LIST_AUTO_DESTROY filtered;
ffListInit(&filtered, sizeof(FFSoundDevice*));
FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFSoundDevice*));
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
{
+1 -2
View File
@@ -7,8 +7,7 @@
void ffPrintUsers(FFinstance* instance)
{
FF_LIST_AUTO_DESTROY users;
ffListInit(&users, sizeof(FFstrbuf));
FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFstrbuf));
FF_STRBUF_AUTO_DESTROY error = ffStrbufCreate();
+1 -2
View File
@@ -7,8 +7,7 @@
void ffPrintWifi(FFinstance* instance)
{
FF_LIST_AUTO_DESTROY result;
ffListInit(&result, sizeof(FFWifiResult));
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult));
const char* error = ffDetectWifi(instance, &result);
if(error)