Mercurial > pidgin
diff src/protocols/oscar/bstream.c @ 10990:8d74ae785a46
[gaim-migrate @ 12828]
More compile warning getting rid of. Also fix the crash from my last
batch of comile warning getting rid ofs.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 09 Jun 2005 04:33:52 +0000 |
parents | de34037a02c7 |
children | b6ca6d3c5332 |
line wrap: on
line diff
--- a/src/protocols/oscar/bstream.c Thu Jun 09 04:15:22 2005 +0000 +++ b/src/protocols/oscar/bstream.c Thu Jun 09 04:33:52 2005 +0000 @@ -131,6 +131,50 @@ return aimutil_getle32(bs->data + bs->offset - 4); } +faim_internal int aimbs_getrawbuf(aim_bstream_t *bs, fu8_t *buf, int len) +{ + + if (aim_bstream_empty(bs) < len) + return 0; + + memcpy(buf, bs->data + bs->offset, len); + bs->offset += len; + + return len; +} + +faim_internal fu8_t *aimbs_getraw(aim_bstream_t *bs, int len) +{ + fu8_t *ob; + + if (!(ob = malloc(len))) + return NULL; + + if (aimbs_getrawbuf(bs, ob, len) < len) { + free(ob); + return NULL; + } + + return ob; +} + +faim_internal char *aimbs_getstr(aim_bstream_t *bs, int len) +{ + char *ob; + + if (!(ob = malloc(len+1))) + return NULL; + + if (aimbs_getrawbuf(bs, ob, len) < len) { + free(ob); + return NULL; + } + + ob[len] = '\0'; + + return ob; +} + faim_internal int aimbs_put8(aim_bstream_t *bs, fu8_t v) { @@ -197,49 +241,6 @@ return 1; } -faim_internal int aimbs_getrawbuf(aim_bstream_t *bs, fu8_t *buf, int len) -{ - - if (aim_bstream_empty(bs) < len) - return 0; - - memcpy(buf, bs->data + bs->offset, len); - bs->offset += len; - - return len; -} - -faim_internal fu8_t *aimbs_getraw(aim_bstream_t *bs, int len) -{ - fu8_t *ob; - - if (!(ob = malloc(len))) - return NULL; - - if (aimbs_getrawbuf(bs, ob, len) < len) { - free(ob); - return NULL; - } - - return ob; -} - -faim_internal char *aimbs_getstr(aim_bstream_t *bs, int len) -{ - char *ob; - - if (!(ob = malloc(len+1))) - return NULL; - - if (aimbs_getrawbuf(bs, ob, len) < len) { - free(ob); - return NULL; - } - - ob[len] = '\0'; - - return ob; -} faim_internal int aimbs_putraw(aim_bstream_t *bs, const fu8_t *v, int len) { @@ -253,6 +254,11 @@ return len; } +faim_internal int aimbs_putstr(aim_bstream_t *bs, const char *str) +{ + aimbs_putraw(bs, str, strlen(str)); +} + faim_internal int aimbs_putbs(aim_bstream_t *bs, aim_bstream_t *srcbs, int len) {