Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_07
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9de1febf
authored
Apr 03, 2025
by
András Bodor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warningok
- új memtrace - unused változók törlése
parent
e1964254
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
15 deletions
+37
-15
Alakzatlab/alakzat2_main.cpp
+1
-1
Alakzatlab/alakzat_main.cpp
+1
-1
Alakzatlab/memtrace.cpp
+16
-10
Alakzatlab/memtrace.h
+19
-3
No files found.
Alakzatlab/alakzat2_main.cpp
View file @
9de1febf
...
...
@@ -37,7 +37,7 @@
using
std
::
cout
;
using
std
::
endl
;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
#if ELKESZULT >= 3 // van rajztábla
Rajztabla
tabla
;
...
...
Alakzatlab/alakzat_main.cpp
View file @
9de1febf
...
...
@@ -26,7 +26,7 @@
using
std
::
cout
;
using
std
::
endl
;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
const
int
N
=
100
;
// maximum 100 alakzatunk lehet
Alakzat
*
idom
[
N
];
...
...
Alakzatlab/memtrace.cpp
View file @
9de1febf
...
...
@@ -5,8 +5,9 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
meset felszabaditaskor: 2018.
me
m
set felszabaditaskor: 2018.
typo: 2019.
poi_check: 2021.
*********************************/
/*definialni kell, ha nem paracssorbol allitjuk be (-DMEMTRACE) */
...
...
@@ -178,7 +179,6 @@ START_NAMESPACE
dying
=
TRUE
;
exit
(
120
);
}
static
void
initialize
();
END_NAMESPACE
...
...
@@ -188,6 +188,7 @@ END_NAMESPACE
#ifdef MEMTRACE_TO_MEMORY
START_NAMESPACE
typedef
struct
_registry_item
{
void
*
p
;
/* mem pointer*/
size_t
size
;
/* size*/
...
...
@@ -197,6 +198,12 @@ START_NAMESPACE
static
registry_item
registry
;
/*sentinel*/
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
static
void
print_registry_item
(
registry_item
*
p
)
{
if
(
p
)
{
print_registry_item
(
p
->
next
);
...
...
@@ -225,6 +232,13 @@ START_NAMESPACE
}
return
0
;
}
/* Ellenorzi, hogy a pointer regisztralt-e. Ha nem, akkor 0-val tér vissza */
int
poi_check
(
void
*
pu
)
{
if
(
pu
==
NULL
)
return
1
;
initialize
();
return
find_registry_item
(
P
(
pu
))
->
next
!=
NULL
;
}
END_NAMESPACE
#endif
/*MEMTRACE_TO_MEMORY*/
...
...
@@ -271,14 +285,6 @@ START_NAMESPACE
return
TRUE
;
}
#ifdef MEMTRACE_TO_MEMORY
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
#endif
static
void
unregister_memory
(
void
*
p
,
call_t
call
)
{
initialize
();
#ifdef MEMTRACE_TO_FILE
...
...
Alakzatlab/memtrace.h
View file @
9de1febf
...
...
@@ -5,7 +5,8 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.,
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
inclue-ok: 2017., 2018., 2019., 2021.
inclue-ok: 2017., 2018., 2019., 2021., 2022.
clang-mágia:Bodor András, 2025
*********************************/
#ifndef MEMTRACE_H
...
...
@@ -101,7 +102,8 @@ END_NAMESPACE
#if defined(MEMTRACE_TO_MEMORY)
START_NAMESPACE
int
mem_check
(
void
);
int
mem_check
(
void
);
int
poi_check
(
void
*
);
END_NAMESPACE
#endif
...
...
@@ -160,6 +162,11 @@ END_NAMESPACE
#include <ostream>
#include <stdexcept>
#include <ctime>
#include <random>
#if __cplusplus >= 201103L
#include <iterator>
#include <regex>
#endif
#endif
#ifdef MEMTRACE_CPP
namespace
std
{
...
...
@@ -187,7 +194,6 @@ START_NAMESPACE
void
mem_dump
(
void
const
*
mem
,
size_t
size
,
FILE
*
fp
=
stdout
);
END_NAMESPACE
#endif
/*MEMTRACE_C*/
...
...
@@ -217,6 +223,16 @@ void operator delete[](void * p, size_t) THROW_NOTHING;
void
operator
delete
(
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
// clang >= 3.1 esetén vannak warningok, amiket zavar, hogy redefiniálva van a new/delete
#if defined(__clang__) && (__clang_major__ > 3 || \
(__clang_major__ == 3 && __clang_minor__ > 0))
// Csak nagyon drasztikus warning szint mellet jön elő, amikor van rekurzívnak tűnő makró.
// Ilyenek a new és delete alább, hiszen olyan, mintha magukat hívnák, pedig nincs (ilyen)
// rekurzió makró szinten.
# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
// Bármilyen kulcsszó újradefiniálása esetén pánikol.
# pragma clang diagnostic ignored "-Wkeyword-macro"
#endif
#define new new(__LINE__, __FILE__)
#define delete memtrace::set_delete_call(__LINE__, __FILE__),delete
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment