root/tags/rel_1-0-1/ext/http11/tst_grow_node_free_list.c

Revision 4, 0.8 kB (checked in by zedshaw, 3 years ago)

initial import into trunk

Line 
1
2 #include "tst.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 int tst_grow_node_free_list(struct tst *tst)
7 {
8    struct node *current_node;
9    struct node_lines *new_line;
10    int i;
11
12    
13    if((new_line = (struct node_lines *) malloc(sizeof(struct node_lines))) == NULL)
14       return TST_ERROR;
15    
16    if((new_line->node_line = (struct node *)
17    calloc(tst->node_line_width, sizeof(struct node))) == NULL)
18    {
19       free(new_line);
20       return TST_ERROR;
21    }
22    else
23    {
24       new_line->next = tst->node_lines;
25       tst->node_lines = new_line;
26    }
27    
28    current_node = tst->node_lines->node_line;
29    tst->free_list = current_node;
30    for (i = 1; i < tst->node_line_width; i++)
31    {
32       current_node->middle = &(tst->node_lines->node_line[i]);
33       current_node = current_node->middle;
34    }
35    current_node->middle = NULL;
36    return 1;
37 }
38
Note: See TracBrowser for help on using the browser.