NetSim Source Code Help
v14.4
All 13 Components
Loading...
Searching...
No Matches
List.h
1
/************************************************************************************
2
* Copyright (C) 2023 *
3
* TETCOS, Bangalore. India *
4
* *
5
* Tetcos owns the intellectual property rights in the Product and its content. *
6
* The copying, redistribution, reselling or publication of any or all of the *
7
* Product or its content without express prior written consent of Tetcos is *
8
* prohibited. Ownership and / or any other right relating to the software and all *
9
* intellectual property rights therein shall remain at all times with Tetcos. *
10
* *
11
* Author: Shashi Kant Suman *
12
* *
13
* ---------------------------------------------------------------------------------*/
14
#pragma once
15
#ifndef _NETSIM_LIST_H_
16
#define _NETSIM_LIST_H_
17
#ifdef __cplusplus
18
extern
"C"
{
19
#endif
20
21
#include <stdio.h>
22
#include <stdlib.h>
23
#include <stddef.h>
24
25
#ifdef _WIN32
26
#pragma comment(lib,"list.lib")
27
#endif
28
29
#define LIST_NEXT(ls) list_next(ls,ls->ele->offset)
30
#define LIST_ADD_LAST(ls,mem) list_add_last(ls,mem->ele->offset,mem,__LINE__,__FILE__)
31
#define LIST_ADD_TOP(ls,mem) list_add_top(ls,mem->ele->offset,mem)
32
#define LIST_FREE(ls,mem) list_free(ls,mem->ele->offset,mem)
33
#define LIST_ADD(ls,mem,checker) list_add(ls,mem,mem->ele->offset,checker)
34
#define LIST_REMOVE(ls,mem) list_remove(ls,mem->ele->offset,mem)
35
#define LIST_SORT(ls,check) list_sort(ls,(*ls)->ele->offset,check)
36
#define list_alloc(size,offset) list_alloc_dbg(size,offset,__LINE__,__FILE__)
37
38
#define BEGIN_LIST(LIST_NAME) typedef struct stru_##LIST_NAME
39
#define END_LIST(LIST_NAME) LIST_NAME,*ptr_##LIST_NAME; \
40
static void* ##LIST_NAME##_ALLOC(){return list_alloc(sizeof(struct stru_##LIST_NAME),offsetof(struct stru_##LIST_NAME,ele));} \
41
static struct stru_##LIST_NAME##* ##LIST_NAME##_NEXT(ptr_##LIST_NAME ls){return (ptr_##LIST_NAME)LIST_NEXT(ls);}
42
43
typedef
struct
element
{
44
size_t
offset;
45
void
* next;
46
void
*prev;
47
} _ele,*_ptr_ele;
48
49
50
51
__inline _ele* list_ele(
void
* list,
size_t
offset);
52
void
* list_alloc_dbg(
size_t
size,
size_t
offset,
int
line,
char
* file);
53
__inline
void
* list_next(
void
* list,
size_t
offset);
54
__inline
void
* list_prev(
void
* list,
size_t
offset);
55
void
list_add(
void
** list,
void
* mem,
size_t
offset,
int
(*check)(
void
* current,
void
* mem));
56
void
list_add_last(
void
** ls,
size_t
offset,
void
* mem,
int
line,
char
* file);
57
void
list_add_top(
void
** list,
size_t
offset,
void
* mem);
58
void
list_free(
void
** list,
size_t
offset,
void
* mem);
59
void
list_sort(
void
** list,
size_t
offset,
int
(*check)(
void
* current,
void
* mem));
//Bubble sort
60
void
list_remove(
void
** list,
size_t
offset,
void
* mem);
61
62
#ifdef __cplusplus
63
}
64
#endif
65
#endif
element
Definition
List.h:43
ALL
Component 1
Part 4
Include
List.h
Generated by
1.13.2