@@ -69,23 +69,24 @@ - (void)installation_proxy_get_appsWithBody:(NSDictionary *)body replyHandler:(n
6969 }
7070
7171 plist_t *app_list = (plist_t *)apps;
72- NSMutableArray * ans = [[ NSMutableArray alloc ] init ];
73- for ( int i = 0 ; i < apps_len; ++i) {
74- char * buf = 0 ;
75- uint32_t plistlen = 0 ;
76- plist_to_bin (app_list[i], &buf, &plistlen );
77- NSError * err2 = 0 ;
78- NSDictionary * appDict = dictionaryFromPlistData ([ NSData dataWithBytes: buf length: plistlen], & err2);
79- plist_mem_free (buf );
80- if (err2) {
81- replyHandler ( nil , @" failed to parse plist data " );
82- return ;
72+ do {
73+ NSMutableArray * ans = [[ NSMutableArray alloc ] init ];
74+ for ( int i = 0 ; i < apps_len; ++i) {
75+ NSError * err2 = 0 ;
76+ NSDictionary * appDict = dictionaryFromPlist (app_list[i], &err2 );
77+
78+ if ( err2) {
79+ replyHandler ( nil , @" failed to parse plist data " );
80+ break ;
81+ }
82+ [ans addObject: appDict] ;
8383 }
84- [ans addObject: appDict];
84+ replyHandler (ans, nil );
85+ } while (0 );
86+
87+ for (int i = 0 ; i < apps_len; ++i) {
88+ plist_free (app_list[i]);
8589 }
86- replyHandler (ans, nil );
87-
88-
8990}
9091
9192- (void )installation_proxy_installWithBody : (NSDictionary *)body replyHandler : (nonnull void (^)(id _Nullable, NSString * _Nullable))replyHandler {
@@ -266,33 +267,33 @@ - (void)installation_proxy_browseWithBody:(NSDictionary *)body replyHandler:(non
266267 plist_from_memory ((void *)[optionsNSData bytes ], (uint32_t )[optionsNSData length ], &optionsPlist, 0 );
267268 }
268269
269- plist_t *apps = NULL ;
270+ plist_t *app_list = NULL ;
270271 size_t apps_len = 0 ;
271- IdeviceFfiError* err = installation_proxy_browse (client, optionsPlist, &apps , &apps_len);
272+ IdeviceFfiError* err = installation_proxy_browse (client, optionsPlist, &app_list , &apps_len);
272273
273274 if (err) {
274275 replyHandler (nil , [self errFreeFromIdeviceFfiError: err]);
275276 return ;
276277 }
277278
278- NSMutableArray * ans = [[NSMutableArray alloc ] init ];
279- for (int i = 0 ; i < apps_len; ++i) {
280- char * buf = 0 ;
281- uint32_t plistlen = 0 ;
282- plist_to_bin (apps[i], &buf, &plistlen);
283- NSError * err2 = 0 ;
284- NSDictionary * appDict = dictionaryFromPlistData ([NSData dataWithBytes: buf length: plistlen], &err2);
285- plist_mem_free (buf);
286- if (err2) {
287- replyHandler (nil , @" failed to parse plist data" );
288- return ;
289- }
290- [ans addObject: appDict];
291- if ([ans count ] >= 100 ) {
292- break ;
279+ do {
280+ NSMutableArray * ans = [[NSMutableArray alloc ] init ];
281+ for (int i = 0 ; i < apps_len; ++i) {
282+ NSError * err2 = 0 ;
283+ NSDictionary * appDict = dictionaryFromPlist (app_list[i], &err2);
284+
285+ if (err2) {
286+ replyHandler (nil , @" failed to parse plist data" );
287+ break ;
288+ }
289+ [ans addObject: appDict];
293290 }
291+ replyHandler (ans, nil );
292+ } while (0 );
293+
294+ for (int i = 0 ; i < apps_len; ++i) {
295+ plist_free (app_list[i]);
294296 }
295- replyHandler (ans, nil );
296297
297298
298299}
0 commit comments