GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
speed2.c
Go to the documentation of this file.
1
2
3
/*
4
** Written by David Gerdes US Army Construction Engineering Research Lab
5
** April 1992
6
** Copyright 1992 USA-CERL All rights reserved.
7
**
8
*/
9
10
/*
11
** This is a simple worst case performance comparison between linkm and malloc
12
*/
13
#include <stdio.h>
14
#include <grass/linkm.h>
15
16
struct
link
17
{
18
char
let
;
19
struct
link
*
next
;
20
};
21
22
/*
23
#define LINKM
24
*/
25
26
int
main
(
int
argc,
char
*argv[])
27
{
28
register
int
i;
29
VOID_T
*head;
30
struct
link
List, *tmp, *p;
31
int
rev = 0;
32
33
34
tmp = &List;
35
36
#ifdef LINKM
37
/* link_set_chunk_size (2000); */
38
head = (
VOID_T
*)
link_init
(
sizeof
(
struct
link
));
39
#endif
40
41
42
for
(i = 0; i < 2000000; i++) {
43
#ifdef LINKM
44
p = (
struct
link
*)
link_new
(head);
45
#else
46
p = (
struct
link
*)malloc(
sizeof
(
struct
link
));
47
#endif
48
tmp->
next
= p;
49
tmp = p;
50
tmp->
next
=
NULL
;
51
}
52
53
for
(p = List.
next
; p !=
NULL
;) {
54
tmp = p->
next
;
55
#ifdef LINKM
56
link_dispose
(head, p);
57
#else
58
free(p);
59
#endif
60
p = tmp;
61
}
62
63
64
#ifdef LINKM
65
link_cleanup
(head);
66
#endif
67
68
exit(0);
69
}
lib
linkm
speed2.c
Generated on Sat Oct 5 2013 12:11:10 for GRASS Programmer's Manual by
1.8.4