Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
OS-Contest-2021-Kernel-Final-Stage2
iPear-syscore
Commits
91ab86e0
Commit
91ab86e0
authored
4 years ago
by
Tianyi Liu
Browse files
Options
Download
Patches
Plain Diff
fix: string bugs
parent
648b57f8
main
C++
NO-PAGEFILE
check_memory_overflow
debug_test
dev
feature/prepare-user-page-table
feature/simplify-heap
fix/elf_pageful
fix/fs
fix/swap-page-table
main-2
new_loader
optimize
submit_test
time_test
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/stl/string.cpp
+5
-5
src/lib/stl/string.cpp
src/lib/stl/string.h
+2
-2
src/lib/stl/string.h
with
7 additions
and
7 deletions
+7
-7
src/lib/stl/string.cpp
+
5
−
5
View file @
91ab86e0
...
...
@@ -28,10 +28,10 @@ String::String(int length):_capacity(length+1),_length(length){
}
String
::
String
(
const
String
&
b
){
_capacity
=
b
.
_length
;
_capacity
=
b
.
_length
+
1
;
_length
=
b
.
_length
;
data
=
new
char
[
_
length
];
memcpy
(
data
,
b
.
data
,
_
length
);
data
=
new
char
[
_
capacity
];
memcpy
(
data
,
b
.
data
,
_
capacity
);
}
char
*
String
::
c_str
()
const
{
...
...
@@ -39,11 +39,11 @@ char* String::c_str()const{
}
int
String
::
length
()
const
{
return
_length
-
1
;
return
_length
;
}
int
String
::
size
()
const
{
return
_length
-
1
;
return
_length
;
}
String
String
::
operator
+
(
const
String
&
b
)
const
{
...
...
This diff is collapsed.
Click to expand it.
src/lib/stl/string.h
+
2
−
2
View file @
91ab86e0
...
...
@@ -6,8 +6,8 @@
class
String
{
public:
const
static
int
__INIT_CAPACITY
=
10
;
int
_capacity
;
int
_length
;
int
_capacity
;
// current vector capacity
int
_length
;
// length without '0' in the end
char
*
data
;
String
(
const
char
*
str
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets