+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Member level 5
    Points: 766, Level: 6

    Join Date
    Jan 2017
    Posts
    80
    Helped
    0 / 0
    Points
    766
    Level
    6

    Randomizing Linked list addresses

    My malloc is allocating consecutive addresses. I want my linked list next address to be a random address instead of consecutive addresses. I know malloc is hard to control; so i wanted to know how to randomize the pointers in the linkedlist? For exxample ; if link1->next = 0xf8 ; link2->next = oxf9; link3->next = 0xf9; I want to make link1->next = 0xf8 ; link2->next = oxfa ; link3->next = 0xf9

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 52,307, Level: 55

    Join Date
    Apr 2011
    Location
    Minneapolis, Minnesota, USA
    Posts
    12,829
    Helped
    2554 / 2554
    Points
    52,307
    Level
    55

    Re: Randomizing Linked list addresses

    One easy trick to obtain random numbers is to grab the contents of a byte of ram which changes continuously. Example, internal time clock.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 80,492, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,192
    Helped
    4407 / 4407
    Points
    80,492
    Level
    69

    Re: Randomizing Linked list addresses

    Methods to generate random numbers is one thing but what is the purpose of randomizing the links in a linked list? Surely, the whole point of a linked list is that each entry points the the next in sequence anyway, no matter what address the link actually points to.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--