🌈 style:

This commit is contained in:
lzy
2024-05-26 15:39:14 +08:00
parent 6f28a3384a
commit a57bbdb4c1
156 changed files with 765 additions and 770 deletions

View File

@@ -3,8 +3,8 @@
struct list_head
{
struct list_head *prev;
struct list_head *next;
struct list_head* prev;
struct list_head* next;
};
#define LIST_HEAD_INIT(name) \
@@ -14,9 +14,9 @@ struct list_head
#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
static inline void __list_add(struct list_head* new,
struct list_head* prev,
struct list_head* next)
{
next->prev = new;
new->next = next;
@@ -24,7 +24,7 @@ static inline void __list_add(struct list_head *new,
prev->next = new;
}
static inline void list_add(struct list_head *new, struct list_head *head)
static inline void list_add(struct list_head* new, struct list_head* head)
{
__list_add(new, head, head->next);
}
@@ -43,12 +43,12 @@ static inline void list_add(struct list_head *new, struct list_head *head)
*
*/
#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER)
#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE*)0)->MEMBER)
#define container_of(ptr, type, member) \
({ \
const typeof(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
#define container_of(ptr, type, member) \
({ \
const typeof(((type*)0)->member)* __mptr = (ptr); \
(type*)((char*)__mptr - offsetof(type, member)); \
})
#define list_entry(ptr, type, member) container_of(ptr, type, member)

View File

@@ -14,16 +14,16 @@ struct score_st
int chinese;
};
static void print_s(struct score_st *d)
static void print_s(struct score_st* d)
{
printf("%d %s %d %d \n", d->id, d->name, d->math, d->chinese);
}
int main()
int main( )
{
int i;
struct score_st *datap;
struct list_head *cur;
struct score_st* datap;
struct list_head* cur;
LIST_HEAD(head);
@@ -35,8 +35,8 @@ int main()
datap->id = i;
snprintf(datap->name, NAMESIZE, "stu%d", i);
datap->math = rand() % 100;
datap->chinese = rand() % 100;
datap->math = rand( ) % 100;
datap->chinese = rand( ) % 100;
list_add(&datap->node, &head);
}