Skip to content

Commit

Permalink
Replace function name
Browse files Browse the repository at this point in the history
  • Loading branch information
uoo723 committed Jun 21, 2017
1 parent 9059b4f commit 9021570
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ typedef struct node {
struct node *next;
} node_t;

node_t *init();
int insert(node_t *, unsigned int, char[VALUESIZE]);
int delete(node_t *, unsigned int);
node_t *get(node_t *, unsigned int);
node_t *ll_create();
int ll_insert(node_t *, unsigned int, char[VALUESIZE]);
int ll_delete(node_t *, unsigned int);
node_t *ll_get(node_t *, unsigned int);

#endif
10 changes: 5 additions & 5 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "node.h"
#include "msg.h"

node_t *init() {
node_t *ll_create() {
node_t *head = NULL;
head = malloc(sizeof(node_t));
if (head == NULL) {
Expand All @@ -16,12 +16,12 @@ node_t *init() {
return head;
}

int insert(node_t *head, unsigned int key, char value[VALUESIZE]) {
int ll_insert(node_t *head, unsigned int key, char value[VALUESIZE]) {
if (head == NULL) {
return -1;
}

node_t *node = get(head, key);
node_t *node = ll_get(head, key);

if (node != NULL) {
return -1;
Expand All @@ -47,7 +47,7 @@ int insert(node_t *head, unsigned int key, char value[VALUESIZE]) {
return 0;
}

int delete(node_t *head, unsigned int key) {
int ll_delete(node_t *head, unsigned int key) {
if (head == NULL) {
return -1;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ int delete(node_t *head, unsigned int key) {
return 0;
}

node_t *get(node_t *head, unsigned int key) {
node_t *ll_get(node_t *head, unsigned int key) {
if (head == NULL) {
return NULL;
}
Expand Down
28 changes: 14 additions & 14 deletions test/node_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
void print(node_t *);

int main() {
node_t *list = init();
node_t *list = ll_create();

if (list == NULL) {
return 0;
}

insert(list, 1, "hello");
insert(list, 2, "world");
insert(list, 3, "Han");
insert(list, 4, "Sangwoo");
insert(list, 5, "woo");
insert(list, 5, "aa");
ll_insert(list, 1, "hello");
ll_insert(list, 2, "world");
ll_insert(list, 3, "Han");
ll_insert(list, 4, "Sangwoo");
ll_insert(list, 5, "woo");
ll_insert(list, 5, "aa");
print(list);

printf("delete test\n");
delete(list, 6);
delete(list, 4);
printf("ll_delete test\n");
ll_delete(list, 6);
ll_delete(list, 4);
print(list);

printf("get test\n");
node_t *temp = get(list, 1);
printf("ll_get test\n");
node_t *temp = ll_get(list, 1);
printf("key: %d, value: %s\n", temp->key, temp->value);
temp = get(list, 6);
temp = ll_get(list, 6);
if (temp == NULL) {
printf("get is null\n");
printf("ll_get is null\n");
}
return 0;
}
Expand Down

0 comments on commit 9021570

Please sign in to comment.