mirror of
https://github.com/Hizenberg469/C1-Linux_SYS_Prog-AS-.git
synced 2026-04-20 02:42:23 +03:00
opaque_pointer
This commit is contained in:
29
opaque_pointer/application.c
Normal file
29
opaque_pointer/application.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* Filename: application.c
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 10/02/24 10:17:06 PM IST
|
||||||
|
* Revision: none
|
||||||
|
* Compiler: gcc
|
||||||
|
*
|
||||||
|
* Author: YOUR NAME (),
|
||||||
|
* Organization:
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "linkedlist.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(){
|
||||||
|
ll_node_t *node1 = malloc_new_node();
|
||||||
|
ll_node_t *node2 = malloc_new_node();
|
||||||
|
|
||||||
|
linkedlist_insertion(node1,node2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
48
opaque_pointer/linkedlist.c
Normal file
48
opaque_pointer/linkedlist.c
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* Filename: linkedlist.c
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 10/02/24 08:55:04 PM IST
|
||||||
|
* Revision: none
|
||||||
|
* Compiler: gcc
|
||||||
|
*
|
||||||
|
* Author: YOUR NAME (),
|
||||||
|
* Organization:
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "linkedlist.h"
|
||||||
|
#include <memory.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct ll_node_{
|
||||||
|
int data;
|
||||||
|
struct ll_node_ *left;
|
||||||
|
struct ll_node_ *right;
|
||||||
|
}ll_node_t;
|
||||||
|
|
||||||
|
void
|
||||||
|
linkedlist_insertion(
|
||||||
|
ll_node_t *current_node,
|
||||||
|
ll_node_t *new_node){
|
||||||
|
|
||||||
|
if( !current_node ){
|
||||||
|
current_node = new_node;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_node->left = new_node;
|
||||||
|
new_node->right = current_node;
|
||||||
|
current_node = new_node;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll_node_t *
|
||||||
|
malloc_new_node(){
|
||||||
|
return (ll_node_t *)malloc(sizeof(ll_node_t));
|
||||||
|
}
|
||||||
34
opaque_pointer/linkedlist.h
Normal file
34
opaque_pointer/linkedlist.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* Filename: linkedlist.h
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 10/02/24 08:40:52 PM IST
|
||||||
|
* Revision: none
|
||||||
|
* Compiler: gcc
|
||||||
|
*
|
||||||
|
* Author: YOUR NAME (),
|
||||||
|
* Organization:
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LINKEDLIST__
|
||||||
|
#define __LINKEDLIST__
|
||||||
|
|
||||||
|
typedef
|
||||||
|
struct ll_node_ ll_node_t;
|
||||||
|
|
||||||
|
|
||||||
|
/*public APIs*/
|
||||||
|
void
|
||||||
|
linkedlist_insertion(
|
||||||
|
ll_node_t *current_node,
|
||||||
|
ll_node_t *new_node);
|
||||||
|
|
||||||
|
ll_node_t *
|
||||||
|
malloc_new_node();
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user