Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
algorithmique
lib_2021_malaspinas
stack
Commits
0d0772c5
Commit
0d0772c5
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Plain Diff
Merge branch '11-add-clone-function' into 'main'
* Added clone function Closes
#11
See merge request
!13
parents
94a4d62f
166b49ca
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!13
Resolve "Add clone function"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stack.c
+9
-0
9 additions, 0 deletions
stack.c
stack.h
+1
-0
1 addition, 0 deletions
stack.h
with
10 additions
and
0 deletions
stack.c
+
9
−
0
View file @
0d0772c5
...
...
@@ -16,3 +16,12 @@ void stack_peek(stack s, int *value){
*
value
=
s
.
data
[
s
.
top
];
}
}
void
stack_clone
(
stack
s
,
stack
*
clone
)
{
clone
->
top
=
s
.
top
;
clone
->
capacity
=
s
.
capacity
;
clone
->
data
=
malloc
(
sizeof
(
int
)
*
s
.
capacity
);
for
(
int
i
=
0
;
i
<=
s
.
top
&&
i
<
s
.
capacity
;
i
++
)
{
clone
->
data
[
i
]
=
s
.
data
[
i
];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack.h
+
1
−
0
View file @
0d0772c5
...
...
@@ -10,5 +10,6 @@ typedef struct _stack {
void
stack_init
(
stack
*
stack
);
void
stack_peek
(
stack
s
,
int
*
value
);
void
stack_clone
(
stack
s
,
stack
*
clone
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment