Discussion:
BongoArray fix
pfelt-Urct4Ww6//Pz1n+
2009-07-09 04:19:02 UTC
Permalink
I've done some test cases on paper and think that the comment here is the
right way. /me would like a double check on the logic before
committing...

mail memmgr-glib # svn diff
Index: src/libs/bongoutil/array.c
===================================================================
--- src/libs/bongoutil/array.c (revision 1098)
+++ src/libs/bongoutil/array.c (working copy)
@@ -149,6 +149,9 @@
return;
}

+ /* i belive the byte count should be
+ * array->data + (array->len * array->elemSize) - array->data + (i *
array->elemSize) + elemSize
+ */
memmove((char *)array->data + (i * array->elemSize),
(char*)array->data + ((i + 1) * array->elemSize),
(array->elemSize * (array->len - i)));
mail memmgr-glib #
pfelt-Urct4Ww6//Pz1n+
2009-07-09 12:17:29 UTC
Permalink
as soon as my head hit the pillow i realized i forgot one set of parens
and cound simplify a bit....

array->data + (array->len * array->elemSize) - (array->data + (i
*array->elemSize) + elemSize)

which simplifies to

(array->len * array->elemSize) - (i * array->elemSize) - elemSize
Post by pfelt-Urct4Ww6//Pz1n+
I've done some test cases on paper and think that the comment here is the
right way. /me would like a double check on the logic before
committing...
mail memmgr-glib # svn diff
Index: src/libs/bongoutil/array.c
===================================================================
--- src/libs/bongoutil/array.c (revision 1098)
+++ src/libs/bongoutil/array.c (working copy)
@@ -149,6 +149,9 @@
return;
}
+ /* i belive the byte count should be
+ * array->data + (array->len * array->elemSize) - array->data + (i *
array->elemSize) + elemSize
+ */
memmove((char *)array->data + (i * array->elemSize),
(char*)array->data + ((i + 1) * array->elemSize),
(array->elemSize * (array->len - i)));
mail memmgr-glib #
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
Alex Hudson
2009-07-09 12:29:19 UTC
Permalink
Hey Pat,

If I'm honest, the array stuff in Bongo always slightly scared me due to
its bare-metal macros implementation.

Is there much of a reason to not use the Glib versions? I got the
impression that many of our data structures were basically nicked
wholesale from there in the first place anyway, and the APIs are
probably so similar it may not be much tougher than a bit of find and
replace refactoring....

Cheers

Alex.
Post by pfelt-Urct4Ww6//Pz1n+
as soon as my head hit the pillow i realized i forgot one set of parens
and cound simplify a bit....
array->data + (array->len * array->elemSize) - (array->data + (i
*array->elemSize) + elemSize)
which simplifies to
(array->len * array->elemSize) - (i * array->elemSize) - elemSize
Post by pfelt-Urct4Ww6//Pz1n+
I've done some test cases on paper and think that the comment here is the
right way. /me would like a double check on the logic before
committing...
mail memmgr-glib # svn diff
Index: src/libs/bongoutil/array.c
===================================================================
--- src/libs/bongoutil/array.c (revision 1098)
+++ src/libs/bongoutil/array.c (working copy)
@@ -149,6 +149,9 @@
return;
}
+ /* i belive the byte count should be
+ * array->data + (array->len * array->elemSize) - array->data + (i *
array->elemSize) + elemSize
+ */
memmove((char *)array->data + (i * array->elemSize),
(char*)array->data + ((i + 1) * array->elemSize),
(array->elemSize * (array->len - i)));
mail memmgr-glib #
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
pfelt-Urct4Ww6//Pz1n+
2009-07-10 03:26:35 UTC
Permalink
I'm all for that actually for lots of reasons. I'm going to look into
making this change tonight and tomorrow. I don't suppose it would be too
bad either.
Post by Alex Hudson
Hey Pat,
If I'm honest, the array stuff in Bongo always slightly scared me due to
its bare-metal macros implementation.
Is there much of a reason to not use the Glib versions? I got the
impression that many of our data structures were basically nicked
wholesale from there in the first place anyway, and the APIs are
probably so similar it may not be much tougher than a bit of find and
replace refactoring....
Cheers
Alex.
Post by pfelt-Urct4Ww6//Pz1n+
as soon as my head hit the pillow i realized i forgot one set of parens
and cound simplify a bit....
array->data + (array->len * array->elemSize) - (array->data + (i
*array->elemSize) + elemSize)
which simplifies to
(array->len * array->elemSize) - (i * array->elemSize) - elemSize
Post by pfelt-Urct4Ww6//Pz1n+
I've done some test cases on paper and think that the comment here is the
right way. /me would like a double check on the logic before
committing...
mail memmgr-glib # svn diff
Index: src/libs/bongoutil/array.c
===================================================================
--- src/libs/bongoutil/array.c (revision 1098)
+++ src/libs/bongoutil/array.c (working copy)
@@ -149,6 +149,9 @@
return;
}
+ /* i belive the byte count should be
+ * array->data + (array->len * array->elemSize) - array->data + (i *
array->elemSize) + elemSize
+ */
memmove((char *)array->data + (i * array->elemSize),
(char*)array->data + ((i + 1) * array->elemSize),
(array->elemSize * (array->len - i)));
mail memmgr-glib #
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
_______________________________________________
Bongo-devel mailing list
https://mail.gna.org/listinfo/bongo-devel
Loading...