Here, we have a program using data llist structure to create a linked list
of integers. Integer species list, because they increase. Five functions,
is used as a callback llist_new received. And LLIST_DEBUG set, llist print
other information have been taken any action. The program is not without
current llist.h and llist.c files, or files datacb.h.
# Include "llist.h"
# Include <string.h>
# Include <stdlib.h>
# Include <stdio.h>
int_dump static void (const void * data)
(
Integrase = ñ * (const Independent *) data;
printf ( "integer:% d a \ N" in, n) a;
)
Static data int_dup invalid * (const void *, size_t n) of the
(
Malloch Independent * I = (sizeof (ICAC));
* I = * (const Independent *) data;
I came back;
)
int_cmp static Independent (const void * D1's, const void * D2 in, size_t
n) of the
(
Independent 1 = * (const Independent *) D1's;
Independent B = * (const Independent * mode) D2;
If (a == b)
Return 0;
If (a "b)
Return 1;
Return -1;
)
Static data int_str character * (const void *, the Independent Commission
Against levels)
(
Character buffer zone [40];
snprintf (buffer zone, 40, "Integer:% d months", * (const Independent
*) data);
Return strdup (buffer belt);
)
Independent body (the Independent Commission Against argc, char ** argv)
(
LL * llist = llist_new (sizeof (internal),
Free, / * Free * /
int_dup, / * NLD * /
memcpy, / * copy * /
int_cmp, / * Chinese * /
int_str / * str * /
)
Independent Commission Against Corruption * tmp's;
Integrase;
As (1 = 0; "10; + + 1)
(
Malloch TMP = (sizeof (ICAC));
* Tmp file = rand ()% 1000;
llist_add_data of the (Q, TMP) of;
)
llist_dump (local employees, 0);
llist_free (1.1);
Return 0;
)
The program will display similar to:
llist.c: 132 lnode_dump (): New lnode: 0x1d6b090 p: (zero) signal to noise
ratio: (zero) Fax: - Data: 0x1d6b070 [Independent Commission Against
Corruption: 383]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b100 p: 0x1d6b090 signal to
noise ratio: (zero) Fax: - Data: 0x1d6b0c0 [Independent Commission Against
Corruption: 886]
llist.c: 132 lnode_dump (): new lnode: 0x1d6b150 p: 0x1d6b090 signal to
noise ratio: 0x1d6b100 Fax: - Data: 0x1d6b0e0 [Independent Commission
Against Corruption: 777]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b1a0 p: 0x1d6b100 signal to
noise ratio: (zero) Fax: - Data: 0x1d6b130 [Independent Commission Against
Corruption: 915]
llist.c: 132 lnode_dump (),: New lnode: 0x1d6b1f0 p: 0x1d6b150 signal to
noise ratio: 0x1d6b100 Fax: - Data: 0x1d6b180 [Independent Commission
Against Corruption: 793]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b240 p: (zero) signal to noise
ratio: 0x1d6b090 Fax: - Data: 0x1d6b1d0 [Independent Commission Against
Corruption: 335]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b290 p: 0x1d6b090 signal to
noise ratio: 0x1d6b150 Fax: - Data: 0x1d6b220 [Independent Commission
Against Corruption: 386]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b2e0 p: 0x1d6b290 signal to
noise ratio: 0x1d6b150 Fax: - Data: 0x1d6b270 [Independent Commission
Against Corruption: 492]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b330 p: 0x1d6b2e0 signal to
noise ratio: 0x1d6b150 Fax: - Data: 0x1d6b2c0 [Independent Commission
Against Corruption: 649]
llist.c: 132 lnode_dump (): New lnode: 0x1d6b380 p: 0x1d6b290 signal to
noise ratio: 0x1d6b2e0 Fax: - Data: 0x1d6b310 [Independent Commission
Against Corruption: 421]
llist.c: 772 llist_dump (): llist: 0x1d6b010
lnode_count: 10
Head: 0x1d6b240
End: 0x1d6b1a0
llist.c: 132 lnode_dump (): lnode: 0x1d6b240 p: (zero) signal to noise
ratio: 0x1d6b090 Fax: - Data: 0x1d6b1d0 [Independent Commission Against
Corruption: 335]
llist.c: 132 lnode_dump (): lnode: 0x1d6b090 p: 0x1d6b240 signal to noise
ratio: 0x1d6b290 Fax: - Data: 0x1d6b070 [Independent Commission Against
Corruption: 383]
llist.c: 132 lnode_dump (): lnode: 0x1d6b290 p: 0x1d6b090 signal to noise
ratio: 0x1d6b380 Fax: - Data: 0x1d6b220 [Independent Commission Against
Corruption: 386]
llist.c: 132 lnode_dump (): lnode: 0x1d6b380 p: 0x1d6b290 signal to noise
ratio: 0x1d6b2e0 Fax: - data: 0x1d6b310 [Independent Commission Against
Corruption: 421]
llist.c: 132 lnode_dump (): lnode: 0x1d6b2e0 p: 0x1d6b380 signal to noise
ratio: 0x1d6b330 Fax: - Data: 0x1d6b270 [Independent Commission Against
Corruption: 492]
llist.c: 132 lnode_dump (): lnode: 0x1d6b330 p: 0x1d6b2e0 signal to noise
ratio: 0x1d6b150 Fax: - Data: 0x1d6b2c0 [Independent Commission Against
Corruption: 649]
llist.c: 132 lnode_dump (): lnode: 0x1d6b150 p: 0x1d6b330 signal to noise
ratio: 0x1d6b1f0 Fax: - Data: 0x1d6b0e0 [Independent Commission Against
Corruption: 777]
llist.c: 132 lnode_dump (): lnode: 0x1d6b1f0 p: 0x1d6b150 signal to noise
ratio: 0x1d6b100 Fax: - Data: 0x1d6b180 [Independent Commission Against
Corruption: 793]
llist.c: 132 lnode_dump (): lnode: 0x1d6b100 p: 0x1d6b1f0 signal to noise
ratio: 0x1d6b1a0 Fax: - Data: 0x1d6b0c0 [Independent Commission Against
Corruption: 886]
llist.c: 132 lnode_dump (): lnode: 0x1d6b1a0 p: 0x1d6b100 signal to noise
ratio: (zero) Fax: - Data: 0x1d6b130 [Independent Commission Against
Corruption: 915]
llist.c: 786 llist_dump (): - In the llist --
_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour