Hi Edward,
The value of the integer parameter 'active_wifis', passed by reference
to 'getRadiatingWifiList' is lost. I added the following line 232:
[....]
*active_wifis = -1;
char* tmp_buffer = scan_buffer;
printf("\nactive_wifis = %i\n\n", active_wifis); /***** ADDED LINE ****/
while((scan_buffer = fgets(scan_buffer, 1024, shell_reader)))
{
z++;
if (z == 1)
active_wifi_list = calloc(sizeof(void*), 10);
[....]
And this is what i get running ./backend 10:
# ./backend 10
active_wifis = -877165076
*** Error in `./backend': realloc(): invalid pointer: 0x00007fff124a3424 ***
Aborted
Cheers,
Aitor.
On 12/06/2015 03:19 PM, Edward Bartolo wrote:
Hi Aitor,
This is my latest edit of the code so that memory allocations are done
when needed instead of the iteration just before more memory is
required.
The edited code:
if (z == 1)
active_wifi_list = calloc(10, sizeof(void*));
else if ((z - 1) % 20 == 0)
active_wifi_list = realloc(active_wifis, (((z - 1)/2) +
10)*sizeof(void*));
Edward
On 06/12/2015, aitor_czr<aitor_...@gnuinos.org> wrote:
>Hi Edward,
>
>I will try it later, thanks:)
>
> Aitor.
>
>On 12/06/2015 01:10 PM, Edward Bartolo wrote:
>>Hi Aitor,
>>
>>I edited the code as follows:
>>
>> if (z == 1)
>> active_wifi_list = calloc(10, sizeof(void*));
>> else if (z % 20 == 0)
>> active_wifi_list = realloc(active_wifis, ((z/2) +
10)*sizeof(void*));
>>
>>Please, if you can run the code and reply back whether it worked. My
>>neighbourhood has less than 10 active wifi repeaters.
>>
>>Edward
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng