file: New ef_typedstr_eq(), factored out of obj_changed()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
e70d8f07f9
commit
7d3a3df283
3 changed files with 19 additions and 14 deletions
|
@ -223,6 +223,7 @@ extern int ef_flush(int);
|
||||||
extern void ef_blank(int, int, void *);
|
extern void ef_blank(int, int, void *);
|
||||||
extern int ef_write(int, int, void *);
|
extern int ef_write(int, int, void *);
|
||||||
extern void ef_set_uid(int, void *, int);
|
extern void ef_set_uid(int, void *, int);
|
||||||
|
extern int ef_typedstr_eq(struct ef_typedstr *, struct ef_typedstr *);
|
||||||
extern int ef_extend(int, int);
|
extern int ef_extend(int, int);
|
||||||
extern int ef_ensure_space(int, int, int);
|
extern int ef_ensure_space(int, int, int);
|
||||||
extern int ef_id_limit(int);
|
extern int ef_id_limit(int);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Dave Pare, 1989
|
* Dave Pare, 1989
|
||||||
* Steve McClure, 2000
|
* Steve McClure, 2000
|
||||||
* Markus Armbruster, 2005-2013
|
* Markus Armbruster, 2005-2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -600,6 +600,19 @@ ef_set_uid(int type, void *buf, int uid)
|
||||||
elt->seqno = get_seqno(ep, uid);
|
elt->seqno = get_seqno(ep, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Are *A and *B equal, except for timestamps and such?
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ef_typedstr_eq(struct ef_typedstr *a, struct ef_typedstr *b)
|
||||||
|
{
|
||||||
|
return a->ef_type == b->ef_type
|
||||||
|
&& a->seqno == b->seqno
|
||||||
|
&& a->uid == b->uid
|
||||||
|
&& !memcmp((char *)a + sizeof(*a), (char *)b + sizeof(*a),
|
||||||
|
empfile[a->ef_type].size - sizeof(*a));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return sequence number of element ID in table EP.
|
* Return sequence number of element ID in table EP.
|
||||||
* Return zero if table is not EFF_TYPED (it has no sequence number
|
* Return zero if table is not EFF_TYPED (it has no sequence number
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Steve McClure, 1998
|
* Steve McClure, 1998
|
||||||
* Markus Armbruster, 2004-2012
|
* Markus Armbruster, 2004-2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -41,24 +41,15 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
|
|
||||||
/* Note that timestamps make things tricky. And, we don't
|
|
||||||
* really care about the timestamp, we just care about the rest
|
|
||||||
* of the structure. So, we make a copy, and zero the timestamps
|
|
||||||
* in both copies, and then compare. */
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
obj_changed(struct empobj *obj)
|
obj_changed(struct empobj *obj)
|
||||||
{
|
{
|
||||||
union empobj_storage old, tobj;
|
union empobj_storage old;
|
||||||
size_t sz;
|
|
||||||
|
|
||||||
if (!get_empobj(obj->ef_type, obj->uid, &old))
|
if (!get_empobj(obj->ef_type, obj->uid, &old))
|
||||||
return 0;
|
return 0;
|
||||||
sz = empfile[obj->ef_type].size;
|
if (!ef_typedstr_eq((struct ef_typedstr *)&old,
|
||||||
memcpy(&tobj, obj, sz);
|
(struct ef_typedstr *)obj))
|
||||||
old.gen.timestamp = tobj.gen.timestamp = 0;
|
|
||||||
old.gen.generation = tobj.gen.generation = 0;
|
|
||||||
if (memcmp(&tobj, &old, sz))
|
|
||||||
return 1;
|
return 1;
|
||||||
ef_mark_fresh(obj->ef_type, obj);
|
ef_mark_fresh(obj->ef_type, obj);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue