Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment Mini Libc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Alexandru-Daniel BARBU
Assignment Mini Libc
Commits
f06f261a
Commit
f06f261a
authored
5 months ago
by
A0Dev0Knight
Browse files
Options
Downloads
Patches
Plain Diff
Fixed warnings.
Signed-off-by:
A0Dev0Knight
<
al.dev.knight@gmail.com
>
parent
e2dbe0dd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#76115
passed
5 months ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mm/malloc.c
+5
-5
5 additions, 5 deletions
src/mm/malloc.c
src/stat/fstatat.c
+8
-1
8 additions, 1 deletion
src/stat/fstatat.c
src/string/string.c
+18
-18
18 additions, 18 deletions
src/string/string.c
with
31 additions
and
24 deletions
src/mm/malloc.c
+
5
−
5
View file @
f06f261a
...
...
@@ -10,21 +10,21 @@
void
*
malloc
(
size_t
size
)
{
/* TODO: Implement malloc(). */
int
long
long
result
=
mmap
(
NULL
,
size
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
);
int
long
long
result
=
(
int
long
long
)
mmap
(
NULL
,
size
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
result
<
0
)
{
return
NULL
;
}
mem_list_add
(
result
,
size
);
mem_list_add
(
(
void
*
)
result
,
size
);
return
(
void
*
)
result
;
}
void
*
calloc
(
size_t
nmemb
,
size_t
size
)
{
/* TODO: Implement calloc(). */
int
long
long
result
=
mmap
(
NULL
,
nmemb
*
size
,
PROT_READ
|
PROT_WRITE
,
MAP_ANONYMOUS
|
MAP_PRIVATE
,
-
1
,
0
);
int
long
long
result
=
(
int
long
long
)
mmap
(
NULL
,
nmemb
*
size
,
PROT_READ
|
PROT_WRITE
,
MAP_ANONYMOUS
|
MAP_PRIVATE
,
-
1
,
0
);
if
(
result
<
0
)
{
...
...
@@ -33,8 +33,8 @@ void *calloc(size_t nmemb, size_t size)
memset
((
void
*
)
result
,
0
,
nmemb
*
size
);
mem_list_add
(
result
,
size
*
nmemb
);
return
result
;
mem_list_add
(
(
void
*
)
result
,
size
*
nmemb
);
return
(
void
*
)
result
;
}
void
free
(
void
*
ptr
)
...
...
This diff is collapsed.
Click to expand it.
src/stat/fstatat.c
+
8
−
1
View file @
f06f261a
...
...
@@ -52,12 +52,19 @@ int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, i
// }
// errno = -result;
(
void
)
fd
;
(
void
)
path
;
(
void
)
st
;
(
void
)
flag
;
return
-
1
;
}
int
fstatat
(
int
fd
,
const
char
*
restrict
path
,
struct
stat
*
restrict
st
,
int
flag
)
{
/* TODO: Implement fstatat(). Use fstatat_statx(). */
(
void
)
fd
;
(
void
)
path
;
(
void
)
st
;
(
void
)
flag
;
return
-
1
;
}
This diff is collapsed.
Click to expand it.
src/string/string.c
+
18
−
18
View file @
f06f261a
...
...
@@ -6,7 +6,7 @@ char *strcpy(char *destination, const char *source)
{
/* TODO: Implement strcpy(). */
char
*
c
=
destination
;
char
*
d
=
source
;
const
char
*
d
=
source
;
while
(
*
d
!=
'\0'
)
{
...
...
@@ -44,7 +44,7 @@ char *strcat(char *destination, const char *source)
c
++
;
}
char
*
d
=
source
;
const
char
*
d
=
source
;
while
(
*
d
!=
'\0'
)
{
...
...
@@ -84,8 +84,8 @@ char *strncat(char *destination, const char *source, size_t len)
int
strcmp
(
const
char
*
str1
,
const
char
*
str2
)
{
/* TODO: Implement strcmp(). */
char
*
s1
=
str1
;
char
*
s2
=
str2
;
const
char
*
s1
=
str1
;
const
char
*
s2
=
str2
;
while
(((
*
s1
)
-
(
*
s2
)
==
0
)
&&
(
*
s1
!=
'\0'
)
&&
(
*
s2
!=
'\0'
))
{
...
...
@@ -112,8 +112,8 @@ int strcmp(const char *str1, const char *str2)
int
strncmp
(
const
char
*
str1
,
const
char
*
str2
,
size_t
len
)
{
/* TODO: Implement strncmp(). */
char
*
s1
=
str1
;
char
*
s2
=
str2
;
const
char
*
s1
=
str1
;
const
char
*
s2
=
str2
;
size_t
offset
=
0
;
...
...
@@ -162,13 +162,13 @@ size_t strlen(const char *str)
char
*
strchr
(
const
char
*
str
,
int
c
)
{
/* TODO: Implement strchr(). */
char
*
d
=
str
;
const
char
*
d
=
str
;
while
(
*
d
!=
'\0'
)
{
if
((
int
)
*
d
==
c
)
{
return
d
;
return
(
char
*
)
d
;
}
d
++
;
}
...
...
@@ -179,14 +179,14 @@ char *strchr(const char *str, int c)
char
*
strrchr
(
const
char
*
str
,
int
c
)
{
/* TODO: Implement strrchr(). */
char
*
d
=
str
;
const
char
*
d
=
str
;
char
*
last
=
NULL
;
while
(
*
d
!=
'\0'
)
{
if
((
int
)
*
d
==
c
)
{
last
=
d
;
last
=
(
char
*
)
d
;
}
d
++
;
}
...
...
@@ -197,8 +197,8 @@ char *strrchr(const char *str, int c)
char
*
strstr
(
const
char
*
haystack
,
const
char
*
needle
)
{
/* TODO: Implement strstr(). */
char
*
hay
=
haystack
;
char
*
ndl
=
needle
;
const
char
*
hay
=
haystack
;
const
char
*
ndl
=
needle
;
char
*
begin
=
NULL
;
while
(
*
hay
!=
'\0'
)
...
...
@@ -207,7 +207,7 @@ char *strstr(const char *haystack, const char *needle)
{
if
(
begin
==
NULL
)
{
begin
=
hay
;
begin
=
(
char
*
)
hay
;
}
ndl
++
;
...
...
@@ -221,7 +221,7 @@ char *strstr(const char *haystack, const char *needle)
// reset ndl to be found
ndl
=
needle
;
begin
=
=
NULL
;
begin
=
NULL
;
}
}
...
...
@@ -235,15 +235,15 @@ char *strstr(const char *haystack, const char *needle)
char
*
strrstr
(
const
char
*
haystack
,
const
char
*
needle
)
{
/* TODO: Implement strrstr(). */
char
*
hay
=
haystack
+
strlen
(
haystack
)
-
1
;
char
*
ndl
=
needle
+
strlen
(
needle
)
-
1
;
const
char
*
hay
=
haystack
+
strlen
(
haystack
)
-
1
;
const
char
*
ndl
=
needle
+
strlen
(
needle
)
-
1
;
char
*
begin
=
NULL
;
while
(
strlen
(
hay
)
!=
strlen
(
haystack
))
{
if
(
*
hay
==
*
ndl
)
{
begin
=
hay
;
begin
=
(
char
*
)
hay
;
ndl
--
;
}
else
{
...
...
@@ -255,7 +255,7 @@ char *strrstr(const char *haystack, const char *needle)
// reset ndl to be found
ndl
=
needle
+
strlen
(
needle
)
-
1
;
begin
=
=
NULL
;
begin
=
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