holding those addresses to "void *" and then to "char *" (so we don't
get warnings from casting directly to "char *" or errors from
subtracting two "void *"s), and subtract them, rather than casting the
pointers to an integral type possibly shorter than the pointers (to
avoid warnings and to avoid the admittedly-infinitesimal chance that the
two pointers don't differ in the bits that fit into the integral type).
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26151
f5534014-38df-0310-8fa8-
9805f1628bb7
#include "mate_util.h"
#include <wsutil/file_util.h>
#include "mate_util.h"
#include <wsutil/file_util.h>
+/***************************************************************************
+* ADDRDIFF
+***************************************************************************
+* This is a macro that computes the difference between the raw address
+* values of two pointers (rather than the difference between the pointers)
+* as a ptrdiff_t.
+***************************************************************************/
+#define ADDRDIFF(p,q) (((char *)(void *)(p)) - ((char *)(void *)(q)))
+
+
/***************************************************************************
* dbg_print
***************************************************************************
/***************************************************************************
* dbg_print
***************************************************************************
extern void merge_avpl(AVPL* dst, AVPL* src, gboolean copy_avps) {
AVPN* cd = NULL;
AVPN* cs = NULL;
extern void merge_avpl(AVPL* dst, AVPL* src, gboolean copy_avps) {
AVPN* cd = NULL;
AVPN* cs = NULL;
AVP* copy;
#ifdef _AVP_DEBUGGING
AVP* copy;
#ifdef _AVP_DEBUGGING
while(cs->avp) {
if(cd->avp) {
while(cs->avp) {
if(cd->avp) {
- c = (guint) cd->avp->n - (guint) cs->avp->n;
+ c = ADDRDIFF(cd->avp->n,cs->avp->n);
AVPL* newavpl;
AVPN* co = NULL;
AVPN* cs = NULL;
AVPL* newavpl;
AVPN* co = NULL;
AVPN* cs = NULL;
AVP* m;
AVP* copy;
gboolean matches;
AVP* m;
AVP* copy;
gboolean matches;
- c = (guint) co->avp->n - (guint) cs->avp->n;
+ c = ADDRDIFF(co->avp->n,cs->avp->n);
if ( c > 0 ) {
delete_avpl(newavpl,TRUE);
if ( c > 0 ) {
delete_avpl(newavpl,TRUE);
AVPL* newavpl = new_avpl(name);
AVPN* co = NULL;
AVPN* cs = NULL;
AVPL* newavpl = new_avpl(name);
AVPN* co = NULL;
AVPN* cs = NULL;
#ifdef _AVP_DEBUGGING
dbg_print(dbg_avpl_op,3,dbg_fp,"new_avpl_every_match: %X src=%X op=%X name='%s'",newavpl,src,op,name);
#ifdef _AVP_DEBUGGING
dbg_print(dbg_avpl_op,3,dbg_fp,"new_avpl_every_match: %X src=%X op=%X name='%s'",newavpl,src,op,name);
co = op->null.next;
while(1) {
co = op->null.next;
while(1) {
- c = (guint) co->avp->n - (guint) cs->avp->n;
+ c = ADDRDIFF(co->avp->n,cs->avp->n);
if ( c > 0 ) {
delete_avpl(newavpl,TRUE);
if ( c > 0 ) {
delete_avpl(newavpl,TRUE);