aboutsummaryrefslogtreecommitdiff
path: root/vis-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-03-29 11:47:23 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-03-30 14:03:12 +0200
commit8bd6650245d050e455cd4d26f6e59e7dd9b80392 (patch)
treeb1ceb33eef645de3cbd4581c46a87dc4dc38a53f /vis-motions.c
parentd407940b6fbbca2eab8a691e4e6d8c3659cbb862 (diff)
downloadvis-8bd6650245d050e455cd4d26f6e59e7dd9b80392.tar.gz
vis-8bd6650245d050e455cd4d26f6e59e7dd9b80392.tar.xz
array: allow arbitrarily sized array elements
There exist two typical ways to use an array: 1) to hold pointers to externally allocated memory regions Use array_init(...) for initialization, an element has the size of a pointer. Use the functions suffixed with `_ptr' to manage your pointers. The cleanup function array_release_full must only be used with this type of array. 2) to hold arbitrary sized objects Use array_init_sized(...) to specify the size of a single element. Use the regular (i.e. without the `_ptr' suffix) functions to manage your objects. array_get will return a pointer to the object stored within the array.
Diffstat (limited to 'vis-motions.c')
-rw-r--r--vis-motions.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vis-motions.c b/vis-motions.c
index 5bff026..3bb0b88 100644
--- a/vis-motions.c
+++ b/vis-motions.c
@@ -234,7 +234,7 @@ int vis_motion_register(Vis *vis, enum VisMotionType type, void *data,
move->type = type;
move->data = data;
- if (array_add(&vis->motions, move))
+ if (array_add_ptr(&vis->motions, move))
return VIS_MOVE_LAST + array_length(&vis->motions) - 1;
free(move);
return -1;
@@ -322,7 +322,7 @@ bool vis_motion(Vis *vis, enum VisMotion motion, ...) {
if (motion < LENGTH(vis_motions))
vis->action.movement = &vis_motions[motion];
else
- vis->action.movement = array_get(&vis->motions, motion - VIS_MOVE_LAST);
+ vis->action.movement = array_get_ptr(&vis->motions, motion - VIS_MOVE_LAST);
if (!vis->action.movement)
goto err;