Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
8
8-s3350363s3500721s3484033s3335739
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Yang, Y. (Yixuan, Student M-CS)
8-s3350363s3500721s3484033s3335739
Commits
b7e65d96
Commit
b7e65d96
authored
3 months ago
by
Pradeep Varma, A. (Adithya, Student M-CS)
Browse files
Options
Downloads
Patches
Plain Diff
add malloc memory check in tree_insert()
parent
8057d7fc
No related branches found
No related tags found
1 merge request
!1
Assignment
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree/src/tree.c
+4
-0
4 additions, 0 deletions
tree/src/tree.c
with
4 additions
and
0 deletions
tree/src/tree.c
+
4
−
0
View file @
b7e65d96
...
...
@@ -98,6 +98,10 @@ void node_insert(Node* node, int age, char* name) {
void
tree_insert
(
Tree
*
tree
,
int
age
,
char
*
name
)
{
if
(
tree
->
root
==
NULL
)
{
Node
*
node
=
malloc
(
sizeof
(
Node
));
if
(
node
==
NULL
)
{
perror
(
"Failed to allocate memory for new node"
);
exit
(
EXIT_FAILURE
);
}
node
->
name
=
name
;
node
->
left
=
NULL
;
node
->
right
=
NULL
;
...
...
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