:: Re: [DNG] Pointer error in the back…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: aitor_czr
Datum:  
To: Edward Bartolo, dng
Betreff: Re: [DNG] Pointer error in the backend of Netman
Hi again,

... "active_wifis" and "&active_wifis" are the same ...

So, forget the comment.

The origin of the pointer error, as Edward said, is in the list of my
neighbouring active wifi points.

Now, i am in another house:

# ./backend 6

ESSID:"Orange-F879"
ESSID:"WLAN_74B3"
ESSID:"Orange-3ECB"
ESSID:"WLAN_75"
ESSID:"PRADOFORD2"

and autoconnection attempts work:

# ./backend 10

Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/00:1b:9e:5f:67:46
Sending on LPF/wlan0/00:1b:9e:5f:67:46
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.1.1
DHCPACK from 192.168.1.1
bound to 192.168.1.101 -- renewal in 2147483648 seconds.


Aitor.

On 12/10/2015 10:07 AM, aitor_czr wrote:
> Changing from:
> realloc(active_wifis
> to:
> realloc(&active_wifis .....
> the pointer error disappears:
>
> # ./backend 10
>
> /sbin/ifup: interface wlan0 already configured
>
> :)
>
> Aitor.
>
> On 12/10/2015 09:58 AM, aitor_czr <aitor_czr@???> wrote:
>> Sorry:
>>
>> printf("\nactive_wifis = %i\n\n", *active_wifis);
>>
>> On 12/10/2015 09:30 AM, aitor_czr wrote:
>>> >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_czr@???> 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