Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-03-10 15:40:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-03-12 16:41:21 +0300
commitb007fa41c6193ab2dc629a4fc40c48010cfc79ac (patch)
tree6b1933d03002ce07ef79231c42720eeeac4004f6 /source/blender/blenloader
parent03c77fbb99fccfc6b1c39264f6b86f9cdcfa09f7 (diff)
Cleanup: use POINTER_OFFSET macro
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c22
-rw-r--r--source/blender/blenloader/intern/readfile.h2
2 files changed, 11 insertions, 13 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b46658f48b1..8f701d26380 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -736,7 +736,7 @@ BHead *blo_firstbhead(FileData *fd)
BHead *blo_prevbhead(FileData *UNUSED(fd), BHead *thisblock)
{
- BHeadN *bheadn = (BHeadN *) (((char *) thisblock) - offsetof(BHeadN, bhead));
+ BHeadN *bheadn = (BHeadN *)POINTER_OFFSET(thisblock, -offsetof(BHeadN, bhead));
BHeadN *prev = bheadn->prev;
return (prev) ? &prev->bhead : NULL;
@@ -750,7 +750,7 @@ BHead *blo_nextbhead(FileData *fd, BHead *thisblock)
if (thisblock) {
/* bhead is actually a sub part of BHeadN
* We calculate the BHeadN pointer from the BHead pointer below */
- new_bhead = (BHeadN *) (((char *) thisblock) - offsetof(BHeadN, bhead));
+ new_bhead = (BHeadN *)POINTER_OFFSET(thisblock, -offsetof(BHeadN, bhead));
/* get the next BHeadN. If it doesn't exist we read in the next one */
new_bhead = new_bhead->next;
@@ -920,7 +920,7 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s
if (chunkoffset+readsize > chunk->size)
readsize= chunk->size-chunkoffset;
- memcpy((char *)buffer + totread, chunk->buf + chunkoffset, readsize);
+ memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
totread += readsize;
filedata->seek += readsize;
seek += readsize;
@@ -5607,7 +5607,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
{
Sequence temp;
- char *poin;
+ void *poin;
intptr_t offset;
offset = ((intptr_t)&(temp.seqbase)) - ((intptr_t)&temp);
@@ -5617,12 +5617,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
ed->seqbasep = &ed->seqbase;
}
else {
- poin = (char *)ed->seqbasep;
- poin -= offset;
+ poin = POINTER_OFFSET(ed->seqbasep, -offset);
poin = newdataadr(fd, poin);
if (poin)
- ed->seqbasep = (ListBase *)(poin+offset);
+ ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
else
ed->seqbasep = &ed->seqbase;
}
@@ -5635,11 +5634,10 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if (ms->oldbasep == old_seqbasep)
ms->oldbasep= &ed->seqbase;
else {
- poin = (char *)ms->oldbasep;
- poin -= offset;
+ poin = POINTER_OFFSET(ms->oldbasep, -offset);
poin = newdataadr(fd, poin);
if (poin)
- ms->oldbasep = (ListBase *)(poin+offset);
+ ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
else
ms->oldbasep = &ed->seqbase;
}
@@ -8037,9 +8035,9 @@ static BHead *find_bhead(FileData *fd, void *old)
return NULL;
}
-char *bhead_id_name(FileData *fd, BHead *bhead)
+const char *bhead_id_name(const FileData *fd, const BHead *bhead)
{
- return ((char *)(bhead+1)) + fd->id_name_offs;
+ return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_name_offs);
}
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 2b40accbf21..281b5e56acf 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -146,7 +146,7 @@ BHead *blo_firstbhead(FileData *fd);
BHead *blo_nextbhead(FileData *fd, BHead *thisblock);
BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
-char *bhead_id_name(FileData *fd, BHead *bhead);
+const char *bhead_id_name(const FileData *fd, const BHead *bhead);
/* do versions stuff */