Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Chris Müller
crystal
Commits
e945050f
Commit
e945050f
authored
Nov 05, 2012
by
Chris Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: use const_pointer in cry_array methods.
lib: add cry_array_clone functions.
parent
f8525c13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
src/structures/array.c
src/structures/array.c
+29
-3
src/structures/array.h
src/structures/array.h
+5
-3
No files found.
src/structures/array.c
View file @
e945050f
...
...
@@ -104,7 +104,7 @@ cry_array_trim(struct CryArray* array)
void
cry_array_append
(
struct
CryArray
*
array
,
pointer
data
,
size_t
size
)
cry_array_append
(
struct
CryArray
*
array
,
const_
pointer
data
,
size_t
size
)
{
assert
(
array
!=
0
);
...
...
@@ -117,7 +117,7 @@ cry_array_append(struct CryArray* array, pointer data, size_t size)
return_code
cry_array_insert
(
struct
CryArray
*
array
,
size_t
index
,
pointer
data
,
size_t
size
)
cry_array_insert
(
struct
CryArray
*
array
,
size_t
index
,
const_
pointer
data
,
size_t
size
)
{
assert
(
array
!=
0
);
...
...
@@ -136,7 +136,7 @@ cry_array_insert(struct CryArray* array, size_t index, pointer data, size_t size
return_code
cry_array_replace
(
struct
CryArray
*
array
,
size_t
index
,
pointer
data
,
size_t
size
)
cry_array_replace
(
struct
CryArray
*
array
,
size_t
index
,
const_
pointer
data
,
size_t
size
)
{
assert
(
array
!=
0
);
...
...
@@ -165,6 +165,16 @@ cry_array_remove(struct CryArray* array, size_t index, size_t size)
void
cry_array_clear
(
struct
CryArray
*
array
)
{
assert
(
array
!=
0
);
array
->
length
=
0
;
}
pointer
cry_array_get
(
struct
CryArray
*
array
,
size_t
index
)
{
...
...
@@ -177,6 +187,22 @@ cry_array_get(struct CryArray* array, size_t index)
}
pointer
cry_array_clone
(
struct
CryArray
*
array
)
{
assert
(
array
!=
0
);
uint8_t
*
ptr
=
0
;
if
(
array
->
length
>
0
)
{
ptr
=
cry_calloc
(
uint8_t
,
array
->
length
);
memcpy
(
ptr
,
array
->
data
,
array
->
length
);
}
return
ptr
;
}
struct
CryPtrArray
{
pointer
*
data
;
...
...
src/structures/array.h
View file @
e945050f
...
...
@@ -51,11 +51,13 @@ size_t cry_array_capacity(struct CryArray* array);
size_t
cry_array_ensure
(
struct
CryArray
*
array
,
size_t
min_capacity
);
size_t
cry_array_trim
(
struct
CryArray
*
array
);
void
cry_array_append
(
struct
CryArray
*
array
,
pointer
data
,
size_t
size
);
return_code
cry_array_insert
(
struct
CryArray
*
array
,
size_t
index
,
pointer
data
,
size_t
size
);
void
cry_array_append
(
struct
CryArray
*
array
,
const_
pointer
data
,
size_t
size
);
return_code
cry_array_insert
(
struct
CryArray
*
array
,
size_t
index
,
const_
pointer
data
,
size_t
size
);
return_code
cry_array_remove
(
struct
CryArray
*
array
,
size_t
index
,
size_t
size
);
return_code
cry_array_replace
(
struct
CryArray
*
array
,
size_t
index
,
pointer
data
,
size_t
size
);
return_code
cry_array_replace
(
struct
CryArray
*
array
,
size_t
index
,
const_pointer
data
,
size_t
size
);
void
cry_array_clear
(
struct
CryArray
*
array
);
pointer
cry_array_clone
(
struct
CryArray
*
array
);
pointer
cry_array_get
(
struct
CryArray
*
array
,
size_t
index
);
...
...
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