Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Seismic
Open ZGY
Commits
21662a2a
Commit
21662a2a
authored
Apr 07, 2021
by
Paal Kvamme
Browse files
Consistent alloc and free.
parent
f3ba09c5
Changes
8
Hide whitespace changes
Inline
Side-by-side
native/src/impl/file_local.cpp
View file @
21662a2a
...
@@ -263,7 +263,7 @@ LocalFileLinux::xx_readv(const ReadList& requests, bool parallel_ok, bool immuta
...
@@ -263,7 +263,7 @@ LocalFileLinux::xx_readv(const ReadList& requests, bool parallel_ok, bool immuta
// terms of the other is an implementation detail.
// terms of the other is an implementation detail.
if
(
!
parallel_ok
||
requests
.
size
()
<
2
)
{
if
(
!
parallel_ok
||
requests
.
size
()
<
2
)
{
for
(
const
ReadRequest
&
r
:
requests
)
{
for
(
const
ReadRequest
&
r
:
requests
)
{
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]);
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]
,
std
::
default_delete
<
char
[]
>
()
);
this
->
LocalFileLinux
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
this
->
LocalFileLinux
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
}
}
...
@@ -286,7 +286,7 @@ LocalFileLinux::xx_readv(const ReadList& requests, bool parallel_ok, bool immuta
...
@@ -286,7 +286,7 @@ LocalFileLinux::xx_readv(const ReadList& requests, bool parallel_ok, bool immuta
const
ReadRequest
&
r
=
requests
[
ii
];
const
ReadRequest
&
r
=
requests
[
ii
];
if
(
datasize
<
r
.
size
||
!
data
||
!
data
.
unique
())
{
if
(
datasize
<
r
.
size
||
!
data
||
!
data
.
unique
())
{
datasize
=
0
;
datasize
=
0
;
data
.
reset
(
new
char
[
r
.
size
]);
data
.
reset
(
new
char
[
r
.
size
]
,
std
::
default_delete
<
char
[]
>
()
);
datasize
=
r
.
size
;
datasize
=
r
.
size
;
}
}
guard
.
run
([
&
](){
guard
.
run
([
&
](){
...
...
native/src/impl/file_sd.cpp
View file @
21662a2a
...
@@ -1156,7 +1156,7 @@ SeismicStoreFile::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
...
@@ -1156,7 +1156,7 @@ SeismicStoreFile::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
#if 0
#if 0
// For now just implement xx_readv in terms of xx_read.
// For now just implement xx_readv in terms of xx_read.
for (const ReadRequest& r : requests) {
for (const ReadRequest& r : requests) {
std::shared_ptr<char> data(new char[r.size]);
std::shared_ptr<char> data(new char[r.size]
, std::default_delete<char[]>()
);
this->SeismicStoreFile::xx_read(data.get(), r.offset, r.size, usagehint);
this->SeismicStoreFile::xx_read(data.get(), r.offset, r.size, usagehint);
_deliver(r.delivery, data, 0, r.size, transient_ok);
_deliver(r.delivery, data, 0, r.size, transient_ok);
}
}
...
@@ -1223,7 +1223,7 @@ SeismicStoreFile::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
...
@@ -1223,7 +1223,7 @@ SeismicStoreFile::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
return
std
::
max
(
a
,
b
.
local_size
+
b
.
outpos
);
return
std
::
max
(
a
,
b
.
local_size
+
b
.
outpos
);
});
});
std
::
shared_ptr
<
char
>
data
(
new
char
[
realsize
]);
std
::
shared_ptr
<
char
>
data
(
new
char
[
realsize
]
,
std
::
default_delete
<
char
[]
>
()
);
if
(
this
->
_config
->
_debug_trace
)
if
(
this
->
_config
->
_debug_trace
)
this
->
_config
->
_debug_trace
(
"readv"
,
/*need=*/
asked
,
/*want=*/
realsize
,
/*parts*/
work
.
size
(),
this
->
_dataset
->
info
()
->
allSizes
(
-
1
));
this
->
_config
->
_debug_trace
(
"readv"
,
/*need=*/
asked
,
/*want=*/
realsize
,
/*parts*/
work
.
size
(),
this
->
_dataset
->
info
()
->
allSizes
(
-
1
));
...
@@ -1810,7 +1810,7 @@ SeismicStoreFileDelayedWrite::xx_readv(const ReadList& requests, bool parallel_o
...
@@ -1810,7 +1810,7 @@ SeismicStoreFileDelayedWrite::xx_readv(const ReadList& requests, bool parallel_o
// of xx_read() or vice versa. Because this is an implementation
// of xx_read() or vice versa. Because this is an implementation
// detail and overriding one of them should not affect the other.
// detail and overriding one of them should not affect the other.
for
(
const
ReadRequest
&
r
:
requests
)
{
for
(
const
ReadRequest
&
r
:
requests
)
{
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]);
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]
,
std
::
default_delete
<
char
[]
>
()
);
this
->
SeismicStoreFileDelayedWrite
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
this
->
SeismicStoreFileDelayedWrite
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
}
}
...
...
native/src/impl/file_smallcache.cpp
View file @
21662a2a
...
@@ -52,7 +52,7 @@ FileWithSmallCache::xx_read(void *data, std::int64_t offset, std::int64_t size,
...
@@ -52,7 +52,7 @@ FileWithSmallCache::xx_read(void *data, std::int64_t offset, std::int64_t size,
}
}
if
(
_cachesize
>
0
)
{
if
(
_cachesize
>
0
)
{
//printf("Cache load offset %llx size %llx\n", 0, _cachesize);
//printf("Cache load offset %llx size %llx\n", 0, _cachesize);
std
::
unique_ptr
<
char
>
newcache
(
new
char
[
_cachesize
]);
std
::
unique_ptr
<
char
[]
>
newcache
(
new
char
[
_cachesize
]);
_relay
->
xx_read
(
newcache
.
get
(),
0
,
_cachesize
,
UsageHint
::
Unknown
);
_relay
->
xx_read
(
newcache
.
get
(),
0
,
_cachesize
,
UsageHint
::
Unknown
);
_cache
.
swap
(
newcache
);
_cache
.
swap
(
newcache
);
}
}
...
...
native/src/impl/file_smallcache.h
View file @
21662a2a
...
@@ -86,7 +86,7 @@ class FileWithSmallCache : public FileADT
...
@@ -86,7 +86,7 @@ class FileWithSmallCache : public FileADT
{
{
private:
private:
std
::
shared_ptr
<
FileADT
>
_relay
;
std
::
shared_ptr
<
FileADT
>
_relay
;
std
::
unique_ptr
<
char
>
_cache
;
std
::
unique_ptr
<
char
[]
>
_cache
;
std
::
int64_t
_cachesize
;
std
::
int64_t
_cachesize
;
FileWithSmallCache
(
const
FileWithSmallCache
&
)
=
delete
;
FileWithSmallCache
(
const
FileWithSmallCache
&
)
=
delete
;
FileWithSmallCache
&
operator
=
(
const
FileWithSmallCache
&
)
=
delete
;
FileWithSmallCache
&
operator
=
(
const
FileWithSmallCache
&
)
=
delete
;
...
...
native/src/impl/file_windows.cpp
View file @
21662a2a
...
@@ -249,7 +249,7 @@ LocalFileWindows::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
...
@@ -249,7 +249,7 @@ LocalFileWindows::xx_readv(const ReadList& requests, bool parallel_ok, bool immu
// xx_readv() to change. The fact that I choose to implement one in
// xx_readv() to change. The fact that I choose to implement one in
// terms of the other is an implementation detail.
// terms of the other is an implementation detail.
for
(
const
ReadRequest
&
r
:
requests
)
{
for
(
const
ReadRequest
&
r
:
requests
)
{
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]);
std
::
shared_ptr
<
char
>
data
(
new
char
[
r
.
size
]
,
std
::
default_delete
<
char
[]
>
()
);
this
->
LocalFileWindows
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
this
->
LocalFileWindows
::
xx_read
(
data
.
get
(),
r
.
offset
,
r
.
size
,
usagehint
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
_deliver
(
r
.
delivery
,
data
,
0
,
r
.
size
,
transient_ok
);
}
}
...
...
native/src/test/test_api.cpp
View file @
21662a2a
...
@@ -1005,7 +1005,7 @@ do_test_copy_slurp_8(const std::string& iname, const std::string& oname, const s
...
@@ -1005,7 +1005,7 @@ do_test_copy_slurp_8(const std::string& iname, const std::string& oname, const s
std
::
shared_ptr
<
OpenZGY
::
IZgyReader
>
reader
=
OpenZGY
::
IZgyReader
::
open
(
iname
);
std
::
shared_ptr
<
OpenZGY
::
IZgyReader
>
reader
=
OpenZGY
::
IZgyReader
::
open
(
iname
);
const
std
::
array
<
std
::
int64_t
,
3
>
orig
{
0
,
0
,
0
};
const
std
::
array
<
std
::
int64_t
,
3
>
orig
{
0
,
0
,
0
};
const
std
::
array
<
std
::
int64_t
,
3
>
size
=
reader
->
size
();
const
std
::
array
<
std
::
int64_t
,
3
>
size
=
reader
->
size
();
std
::
unique_ptr
<
float
>
buf
(
new
float
[
size
[
0
]
*
size
[
1
]
*
size
[
2
]]);
std
::
unique_ptr
<
float
[]
>
buf
(
new
float
[
size
[
0
]
*
size
[
1
]
*
size
[
2
]]);
reader
->
read
(
orig
,
size
,
buf
.
get
(),
0
);
reader
->
read
(
orig
,
size
,
buf
.
get
(),
0
);
// write
// write
...
...
native/src/test/test_consolidate.cpp
View file @
21662a2a
...
@@ -117,7 +117,7 @@ test_one()
...
@@ -117,7 +117,7 @@ test_one()
TEST_CHECK
(
result
[
0
].
offset
==
list
[
0
].
offset
);
TEST_CHECK
(
result
[
0
].
offset
==
list
[
0
].
offset
);
TEST_CHECK
(
result
[
0
].
size
==
list
[
0
].
size
);
TEST_CHECK
(
result
[
0
].
size
==
list
[
0
].
size
);
TEST_CHECK
((
bool
)
result
[
0
].
delivery
);
TEST_CHECK
((
bool
)
result
[
0
].
delivery
);
std
::
shared_ptr
<
int
>
data
(
new
int
[
list
[
0
].
size
]);
std
::
shared_ptr
<
int
>
data
(
new
int
[
list
[
0
].
size
]
,
std
::
default_delete
<
int
[]
>
()
);
data
.
get
()[
0
]
=
list
[
0
].
offset
;
data
.
get
()[
0
]
=
list
[
0
].
offset
;
data
.
get
()[
1
]
=
list
[
0
].
size
;
data
.
get
()[
1
]
=
list
[
0
].
size
;
for
(
std
::
int64_t
ii
=
2
;
ii
<
list
[
0
].
size
;
++
ii
)
for
(
std
::
int64_t
ii
=
2
;
ii
<
list
[
0
].
size
;
++
ii
)
...
@@ -159,7 +159,7 @@ run_test(const ReadList& list_in,
...
@@ -159,7 +159,7 @@ run_test(const ReadList& list_in,
// Pretend we read this data file a file. The raw data contains the
// Pretend we read this data file a file. The raw data contains the
// offset from the start of the buffer so we can check what was sent.
// offset from the start of the buffer so we can check what was sent.
std
::
shared_ptr
<
int
>
data
(
new
int
[
filesize
/
sizeof
(
int
)]);
std
::
shared_ptr
<
int
>
data
(
new
int
[
filesize
/
sizeof
(
int
)]
,
std
::
default_delete
<
int
[]
>
()
);
for
(
std
::
size_t
ii
=
0
;
ii
<
filesize
/
sizeof
(
int
);
++
ii
)
for
(
std
::
size_t
ii
=
0
;
ii
<
filesize
/
sizeof
(
int
);
++
ii
)
data
.
get
()[
ii
]
=
sizeof
(
int
)
*
static_cast
<
int
>
(
ii
);
data
.
get
()[
ii
]
=
sizeof
(
int
)
*
static_cast
<
int
>
(
ii
);
...
...
native/src/test/test_utils.cpp
View file @
21662a2a
...
@@ -430,8 +430,8 @@ compare_files(const std::string& a_name, const std::string& b_name, double epsil
...
@@ -430,8 +430,8 @@ compare_files(const std::string& a_name, const std::string& b_name, double epsil
const
std
::
int32_t
nlods
=
std
::
min
(
a
.
nlods
(),
b
.
nlods
());
const
std
::
int32_t
nlods
=
std
::
min
(
a
.
nlods
(),
b
.
nlods
());
const
float
nan
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
const
float
nan
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
const
std
::
array
<
std
::
int64_t
,
3
>
orig
{
0
,
0
,
0
};
const
std
::
array
<
std
::
int64_t
,
3
>
orig
{
0
,
0
,
0
};
std
::
unique_ptr
<
float
>
a_data
(
new
float
[
count
]);
std
::
unique_ptr
<
float
[]
>
a_data
(
new
float
[
count
]);
std
::
unique_ptr
<
float
>
b_data
(
new
float
[
count
]);
std
::
unique_ptr
<
float
[]
>
b_data
(
new
float
[
count
]);
std
::
fill
(
a_data
.
get
(),
a_data
.
get
()
+
count
,
nan
);
std
::
fill
(
a_data
.
get
(),
a_data
.
get
()
+
count
,
nan
);
std
::
fill
(
b_data
.
get
(),
b_data
.
get
()
+
count
,
nan
);
std
::
fill
(
b_data
.
get
(),
b_data
.
get
()
+
count
,
nan
);
float
*
aptr
=
a_data
.
get
();
float
*
aptr
=
a_data
.
get
();
...
...
Write
Preview
Supports
Markdown
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