Skip to content

Commit

Permalink
task upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jekwupeter committed Jun 16, 2022
0 parents commit c4d5913
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test
29 changes: 29 additions & 0 deletions dlinked_list_functions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "monty.h"
/**
* add_dnodeint - adds a new node to beggining of dlinked list
* @stack_ptr: pointer to top of dlinked list
* @n: input data for new node
*
* Return: adress to new dnode added
*
* */
stack_t *add_dnodeint(stack_t **stack_ptr, const int n)
{
stack_t *new_node;

/* allocate memory to node */
new_node = (stack_t *)malloc(sizeof(stack_t));
if (new_node == NULL)
return (NULL);

new_node->n = n;/* put in data*/
/* make next of new node as head & prev as NULL */
new_node->next = n;
new_node->prev = NULL;

/* change the prev of head node to new node */
if ((*stack_ptr) != NULL)
(*stack_ptr)->prev = new_node

return (newnode);
}
32 changes: 32 additions & 0 deletions monty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef MONTY_H
#define MONTY_H
/**
* struct stack_s - doubly linked list representation of a stack (or queue)
* @n: integer
* @prev: points to the previous element of the stack (or queue)
* @next: points to the next element of the stack (or queue)
*
* Description: doubly linked list node structure
* for stack, queues, LIFO, FIFO
*/
typedef struct stack_s
{
int n;
struct stack_s *prev;
struct stack_s *next;
} stack_t;
/**
* struct instruction_s - opcode and its function
* @opcode: the opcode
* @f: function to handle the opcode
*
* Description: opcode and its function
* for stack, queues, LIFO, FIFO
*/
typedef struct instruction_s
{
char *opcode;
void (*f)(stack_t **stack, unsigned int line_number);
} instruction_t;
extern stack_t *stack_ptr = NULL;
#endif

0 comments on commit c4d5913

Please sign in to comment.