N
nusch
I've problem with mini version control system, quickly reviewing -
class Repository has list of pointers to class Revision, class
Revision has map<string, Patch*> which maps filename to patch.
Patch derrives from File, File has vector<string> lines.
Here all the files, sory but I can't seperate the problem
main.cpp http://pastebin.com/f83YA1G6
file.h http://pastebin.com/0gUiRwz6
repo.h http://pastebin.com/RxX94RXJ
file.cpp http://pastebin.com/7wrQrBtn
repo.cpp http://pastebin.com/wwkUJ1nk
revision.h http://pastebin.com/nTMu9yRx
revision.cpp http://pastebin.com/aq5J29Cg
LongestCommonSubsequence.hpp http://pastebin.com/HHmKmCF1
Whole logic seems to be ok, I've locked copy constructor as explicit
to prevent temporary objects, all objects are created by new, although
somewhat some memory is deleted before (file.cpp line 200)
void File::add_line(string line) {
lines.push_back(line);
}
valgrind shows that info:
==29517== Invalid read of size 8
==29517== at 0x405678: std::vector<std::string,
std::allocator<std::string> >:ush_back(std::string const&)
(stl_vector.h:735)
==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200)
==29517== by 0x40C32C: Revision:arse() (revision.cpp:35)
==29517== by 0x40944D: Repo::load() (repo.cpp:65)
==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109)
==29517== by 0x40970E: Repo::commit() (repo.cpp:97)
==29517== by 0x408997: main (main.cpp:58)
==29517== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==29517==
==29517==
==29517== Process terminating with default action of signal 11
(SIGSEGV)
==29517== Access not within mapped region at address 0x10
==29517== at 0x405678: std::vector<std::string,
std::allocator<std::string> >:ush_back(std::string const&)
(stl_vector.h:735)
==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200)
==29517== by 0x40C32C: Revision:arse() (revision.cpp:35)
==29517== by 0x40944D: Repo::load() (repo.cpp:65)
==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109)
==29517== by 0x40970E: Repo::commit() (repo.cpp:97)
==29517== by 0x408997: main (main.cpp:58)
It's points line with push_back, but if I passing string by value
what can cause that the string inside function is deleted ? Or what
line in backtrace is wrong?
class Repository has list of pointers to class Revision, class
Revision has map<string, Patch*> which maps filename to patch.
Patch derrives from File, File has vector<string> lines.
Here all the files, sory but I can't seperate the problem
main.cpp http://pastebin.com/f83YA1G6
file.h http://pastebin.com/0gUiRwz6
repo.h http://pastebin.com/RxX94RXJ
file.cpp http://pastebin.com/7wrQrBtn
repo.cpp http://pastebin.com/wwkUJ1nk
revision.h http://pastebin.com/nTMu9yRx
revision.cpp http://pastebin.com/aq5J29Cg
LongestCommonSubsequence.hpp http://pastebin.com/HHmKmCF1
Whole logic seems to be ok, I've locked copy constructor as explicit
to prevent temporary objects, all objects are created by new, although
somewhat some memory is deleted before (file.cpp line 200)
void File::add_line(string line) {
lines.push_back(line);
}
valgrind shows that info:
==29517== Invalid read of size 8
==29517== at 0x405678: std::vector<std::string,
std::allocator<std::string> >:ush_back(std::string const&)
(stl_vector.h:735)
==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200)
==29517== by 0x40C32C: Revision:arse() (revision.cpp:35)
==29517== by 0x40944D: Repo::load() (repo.cpp:65)
==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109)
==29517== by 0x40970E: Repo::commit() (repo.cpp:97)
==29517== by 0x408997: main (main.cpp:58)
==29517== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==29517==
==29517==
==29517== Process terminating with default action of signal 11
(SIGSEGV)
==29517== Access not within mapped region at address 0x10
==29517== at 0x405678: std::vector<std::string,
std::allocator<std::string> >:ush_back(std::string const&)
(stl_vector.h:735)
==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200)
==29517== by 0x40C32C: Revision:arse() (revision.cpp:35)
==29517== by 0x40944D: Repo::load() (repo.cpp:65)
==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109)
==29517== by 0x40970E: Repo::commit() (repo.cpp:97)
==29517== by 0x408997: main (main.cpp:58)
It's points line with push_back, but if I passing string by value
what can cause that the string inside function is deleted ? Or what
line in backtrace is wrong?