Some of the news flash items on SVTechie is causing display template to break down in Internet Explorer. Though everything is workin in Firefox.
 

Main Menu

Home
Articles
SVTechie Blog
Links
Download
Discussion Forum
Photo Gallery
Quick Bites
FAQs

Login






Lost Password?
No account yet? Register

Statistics

We have 2 guests online

SVTechie Recommends


powered_by.png, 1 kB

Text Links


Home
Dynamic Memory Allocation Performance PDF Print E-mail
Written by SVTechie   
Sunday, 09 April 2006
Article Index
Dynamic Memory Allocation Performance
Quick Notes on Memory Allocation
ANSI C Linked List Code
C Linked List Code
Record Collapsing
Pool Based Library Implementation
Conclusion
 

 

This implementation is very simple Linked List Implementation. A single link list is created with  same number of nodes as number of datasets, resulting in large number of allocation and deallocation requests. Following is the code snippet for this algorithm.

 

 ANSI C Linked List Implementation
 

#include <stdio.h>

typedef struct nodedef {
        int data;
        struct nodedef *next;
        } node;

void main () {
  node *str, *tmp, *cur;
  int i;

  str = cur = NULL;
  for (i = 0; i < NUM_REQUEST; i++) {  

    // Create New Node   

    tmp = (node *) malloc (sizeof(node));

    tmp->data = i;    

    tmp->next = NULL;   

    // Insert in the list   

    if (str == NULL) {     

       // First Node     

       str = tmp;   

    } else {     

        // Insert at End (pointed by cur)     

        cur->next = tmp;
    }
    cur = tmp;
  }

  // Deallocate each node
  tmp = str;
  for (cur = str->next; cur != NULL; cur = cur->next) {
    free (tmp);
    tmp = cur;
  }

}

 



Last Updated ( Saturday, 06 May 2006 )
 
Next >
Home Loan | Loan | Mobile Phones | Problem Mortgage | Loans
© 2008 SVTechie :: Online Resources For Techies BY Techies
Joomla! is Free Software released under the GNU/GPL License.