-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink_int.c
More file actions
38 lines (38 loc) · 873 Bytes
/
Copy pathlink_int.c
File metadata and controls
38 lines (38 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
#include <stdio.h>
#include "link_int.h"
/**
* return:
* 0: success , 1 : header none, 2: no memory
*/
//int data 可以改写为 void* data,使其更加通用
int list_insert_node(p_link_node header, int data)
{
p_link_node pnode = NULL;
/*
if(header != NULL)
return 1;
*/
pnode = (p_link_node)malloc(sizeof(link_node));
if(pnode == NULL)
return 2;
pnode->data = data;
pnode->next = header->next;
header->next = pnode;
//printf("weijinhua");
return 0;
}
//摘取头部数据,并将节点从链表中擦除
//return
// 1: no memory spacee , 0: success
int list_pick_node(p_link_node header, int* data)
{
p_link_node tpnode;
tpnode = header->next;
if (tpnode == NULL)
return 1;
header->next = tpnode->next;
*data = tpnode->data;
free(tpnode);
return 0;
}