diff options
-rw-r--r-- | binutils/ChangeLog | 4 | ||||
-rw-r--r-- | binutils/resbin.c | 42 |
2 files changed, 25 insertions, 21 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 20b8433..92a732b 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2006-03-29 Ben Elliston <bje@au.ibm.com> + + * resbin.c: Avoid duplicating constants in calls to reswr_alloc. + 2006-03-20 Nathan Sidwell <nathan@codesourcery.com> * BRANCHES: Remove binutils-csl-arm-2006q1-branch. Document diff --git a/binutils/resbin.c b/binutils/resbin.c index 2c20a27..80c2596 100644 --- a/binutils/resbin.c +++ b/binutils/resbin.c @@ -1331,7 +1331,7 @@ resid_to_bin (struct res_id id, int big_endian) if (! id.named) { d->length = 4; - d->data = (unsigned char *) reswr_alloc (4); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, 0xffff, d->data); put_16 (big_endian, id.u.id, d->data + 2); } @@ -1408,7 +1408,7 @@ res_to_bin_accelerator (const struct accelerator *accelerators, d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 8; - d->data = (unsigned char *) reswr_alloc (8); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, a->flags | (a->next != NULL ? 0 : ACC_LAST), @@ -1434,7 +1434,7 @@ res_to_bin_cursor (const struct cursor *c, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 4; - d->data = (unsigned char *) reswr_alloc (4); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, c->xhotspot, d->data); put_16 (big_endian, c->yhotspot, d->data + 2); @@ -1459,7 +1459,7 @@ res_to_bin_group_cursor (const struct group_cursor *group_cursors, first = (struct bindata *) reswr_alloc (sizeof *first); first->length = 6; - first->data = (unsigned char *) reswr_alloc (6); + first->data = (unsigned char *) reswr_alloc (first->length); put_16 (big_endian, 0, first->data); put_16 (big_endian, 2, first->data + 2); @@ -1476,7 +1476,7 @@ res_to_bin_group_cursor (const struct group_cursor *group_cursors, d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 14; - d->data = (unsigned char *) reswr_alloc (14); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, gc->width, d->data); put_16 (big_endian, gc->height, d->data + 2); @@ -1642,7 +1642,7 @@ res_to_bin_dialog (const struct dialog *dialog, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 2; - d->data = (unsigned char *) reswr_alloc (2); + d->data = (unsigned char *) reswr_alloc (d->length); length += 2; @@ -1687,7 +1687,7 @@ res_to_bin_fontdir (const struct fontdir *fontdirs, int big_endian) first = (struct bindata *) reswr_alloc (sizeof *first); first->length = 2; - first->data = (unsigned char *) reswr_alloc (2); + first->data = (unsigned char *) reswr_alloc (first->length); first->next = NULL; pp = &first->next; @@ -1701,7 +1701,7 @@ res_to_bin_fontdir (const struct fontdir *fontdirs, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 2; - d->data = (unsigned char *) reswr_alloc (2); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, fd->index, d->data); @@ -1733,7 +1733,7 @@ res_to_bin_group_icon (const struct group_icon *group_icons, int big_endian) first = (struct bindata *) reswr_alloc (sizeof *first); first->length = 6; - first->data = (unsigned char *) reswr_alloc (6); + first->data = (unsigned char *) reswr_alloc (first->length); put_16 (big_endian, 0, first->data); put_16 (big_endian, 1, first->data + 2); @@ -1750,7 +1750,7 @@ res_to_bin_group_icon (const struct group_icon *group_icons, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 14; - d->data = (unsigned char *) reswr_alloc (14); + d->data = (unsigned char *) reswr_alloc (d->length); d->data[0] = gi->width; d->data[1] = gi->height; @@ -1875,7 +1875,7 @@ res_to_bin_menuexitems (const struct menuitem *items, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 12; - d->data = (unsigned char *) reswr_alloc (12); + d->data = (unsigned char *) reswr_alloc (d->length); length += 12; @@ -1903,7 +1903,7 @@ res_to_bin_menuexitems (const struct menuitem *items, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 4; - d->data = (unsigned char *) reswr_alloc (4); + d->data = (unsigned char *) reswr_alloc (d->length); put_32 (big_endian, mi->help, d->data); @@ -1948,13 +1948,13 @@ res_to_bin_rcdata (const struct rcdata_item *items, int big_endian) case RCDATA_WORD: d->length = 2; - d->data = (unsigned char *) reswr_alloc (2); + d->data = (unsigned char *) reswr_alloc (d->length); put_16 (big_endian, ri->u.word, d->data); break; case RCDATA_DWORD: d->length = 4; - d->data = (unsigned char *) reswr_alloc (4); + d->data = (unsigned char *) reswr_alloc (d->length); put_32 (big_endian, ri->u.dword, d->data); break; @@ -2060,7 +2060,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) first = (struct bindata *) reswr_alloc (sizeof *first); first->length = 6; - first->data = (unsigned char *) reswr_alloc (6); + first->data = (unsigned char *) reswr_alloc (first->length); length = 6; @@ -2086,7 +2086,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) d = (struct bindata *) reswr_alloc (sizeof *d); d->length = 52; - d->data = (unsigned char *) reswr_alloc (52); + d->data = (unsigned char *) reswr_alloc (d->length); length += 52; @@ -2120,7 +2120,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) vid = (struct bindata *) reswr_alloc (sizeof *vid); vid->length = 6; - vid->data = (unsigned char *) reswr_alloc (6); + vid->data = (unsigned char *) reswr_alloc (vid->length); length += 6; vilen = 6; @@ -2153,7 +2153,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) vsd = (struct bindata *) reswr_alloc (sizeof *vsd); vsd->length = 6; - vsd->data = (unsigned char *) reswr_alloc (6); + vsd->data = (unsigned char *) reswr_alloc (vsd->length); length += 6; vilen += 6; @@ -2183,7 +2183,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) vssd = (struct bindata *) reswr_alloc (sizeof *vssd); vssd->length = 6; - vssd->data = (unsigned char *) reswr_alloc (6); + vssd->data = (unsigned char *) reswr_alloc (vssd->length); length += 6; vilen += 6; @@ -2241,7 +2241,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) vvd = (struct bindata *) reswr_alloc (sizeof *vvd); vvd->length = 6; - vvd->data = (unsigned char *) reswr_alloc (6); + vvd->data = (unsigned char *) reswr_alloc (vvd->length); length += 6; vilen += 6; @@ -2271,7 +2271,7 @@ res_to_bin_versioninfo (const struct versioninfo *versioninfo, int big_endian) vvsd = (struct bindata *) reswr_alloc (sizeof *vvsd); vvsd->length = 4; - vvsd->data = (unsigned char *) reswr_alloc (4); + vvsd->data = (unsigned char *) reswr_alloc (vvsd->length); length += 4; vilen += 4; |