-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmul.c
More file actions
35 lines (32 loc) · 630 Bytes
/
Copy pathmul.c
File metadata and controls
35 lines (32 loc) · 630 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
#include "monty.h"
/**
* _mul - es the second top element of the stack with the
* top element of the stack
* @stack: head
* @num_line: integer
*/
void _mul(stack_t **stack, unsigned int num_line)
{
stack_t *temp1;
stack_t *temp2;
int mult = 0;
if (*stack && (*stack)->next)
{
temp2 = (*stack)->next;
mult = temp2->n * (*stack)->n;
temp1 = *stack;
*stack = (*stack)->next;
if (*stack)
(*stack)->prev = NULL;
free(temp1);
(*stack)->n = mult;
}
else
{
dprintf(2, "L%u: can't mul, stack too short\n", num_line);
free(global.line);
fclose(global.fil);
free_l(stack);
exit(EXIT_FAILURE);
}
}