Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
61
Issues
61
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
bbc31806
Commit
bbc31806
authored
Jan 06, 2012
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: fix apk_array copying, and additional size_t fixes
parent
a80cdfe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
src/apk_defines.h
src/apk_defines.h
+1
-0
src/common.c
src/common.c
+4
-2
No files found.
src/apk_defines.h
View file @
bbc31806
...
...
@@ -108,6 +108,7 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size);
static inline void \
array_type_name##_copy(struct array_type_name **a, struct array_type_name *b)\
{ \
if (*a == b) return; \
*a = apk_array_resize(*a, b->num, sizeof(elem_type_name));\
memcpy((*a)->item, b->item, b->num * sizeof(elem_type_name));\
} \
...
...
src/common.c
View file @
bbc31806
...
...
@@ -10,13 +10,15 @@
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include "apk_defines.h"
static
int
*
dummy_array
=
0
;
void
*
apk_array_resize
(
void
*
array
,
size_t
new_size
,
size_t
elem_size
)
{
int
old_size
,
diff
;
size_t
old_size
;
ssize_t
diff
;
void
*
tmp
;
if
(
new_size
==
0
)
{
...
...
@@ -25,7 +27,7 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
return
&
dummy_array
;
}
old_size
=
array
?
*
((
int
*
)
array
)
:
0
;
old_size
=
array
?
*
((
size_t
*
)
array
)
:
0
;
diff
=
new_size
-
old_size
;
if
(
array
==
&
dummy_array
)
...
...
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