[maemo-commits] [maemo-commits] r15411 - in projects/haf/trunk/maemo-launcher: . launcher
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Apr 16 01:35:27 EEST 2008
- Previous message: [maemo-commits] r15410 - in projects/haf/trunk/maemo-launcher: . launcher
- Next message: [maemo-commits] r15412 - in projects/haf/trunk/maemo-launcher: . launcher
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: guillem Date: 2008-04-16 01:35:26 +0300 (Wed, 16 Apr 2008) New Revision: 15411 Modified: projects/haf/trunk/maemo-launcher/ChangeLog projects/haf/trunk/maemo-launcher/launcher/comm_msg.c projects/haf/trunk/maemo-launcher/launcher/comm_msg.h Log: Add a need_size argument to comm_msg_grow Modified: projects/haf/trunk/maemo-launcher/ChangeLog =================================================================== --- projects/haf/trunk/maemo-launcher/ChangeLog 2008-04-15 22:35:24 UTC (rev 15410) +++ projects/haf/trunk/maemo-launcher/ChangeLog 2008-04-15 22:35:26 UTC (rev 15411) @@ -1,5 +1,14 @@ 2008-02-21 Guillem Jover <guillem.jover at nokia.com> + * launcher/comm_msg.h (comm_msg_grow): Add a need_size argument. + (comm_msg_grow): Likewise. Remove implicit end_size calculations. + Fix all callers. + (comm_msg_pack_mem): Check comm_msg_grow return code and set + msg->used after calling it. + (comm_msg_recv): Likewise. + +2008-02-21 Guillem Jover <guillem.jover at nokia.com> + * launcher/test_lib.h (test_success): New function declaration. (test_failure): Likewise. * launcher/test_lib.c (test_success): New function. Modified: projects/haf/trunk/maemo-launcher/launcher/comm_msg.c =================================================================== --- projects/haf/trunk/maemo-launcher/launcher/comm_msg.c 2008-04-15 22:35:24 UTC (rev 15410) +++ projects/haf/trunk/maemo-launcher/launcher/comm_msg.c 2008-04-15 22:35:26 UTC (rev 15411) @@ -72,18 +72,19 @@ } bool -comm_msg_grow(comm_msg_t *msg) +comm_msg_grow(comm_msg_t *msg, uint32_t need_size) { uint32_t end_size; void *p; - if (msg->used > msg->size) - /* Direct request for size growing. */ - end_size = msg->used; - else - /* Automatic request for size growing. */ - end_size = msg->size << 1; + if (msg->size - msg->used >= need_size) + return true; + end_size = msg->size + need_size; + + /* Add some more space. */ + end_size += msg->size; + p = realloc(msg->buf, end_size); if (!p) return false; @@ -111,11 +112,11 @@ uint32_t aligned_size = WORD_ALIGN(size); uint32_t pad_size = aligned_size - size; + if (!comm_msg_grow(msg, aligned_size + sizeof(uint32_t))) + return false; + msg->used += aligned_size + sizeof(uint32_t); - if (msg->used > msg->size) - comm_msg_grow(msg); - /* Pack the size. */ memcpy(cur, &aligned_size, sizeof(uint32_t)); @@ -225,13 +226,16 @@ bool comm_msg_recv(int fd, comm_msg_t *msg) { - read(fd, &msg->used, sizeof(msg->used)); + uint32_t size; - if (msg->used > msg->size) - comm_msg_grow(msg); + read(fd, &size, sizeof(size)); - read(fd, msg->buf, msg->used); + if (!comm_msg_grow(msg, size)) + return false; + read(fd, msg->buf, size); + msg->used = size; + debug("%s: %08x\n", __FUNCTION__, *msg); return true; Modified: projects/haf/trunk/maemo-launcher/launcher/comm_msg.h =================================================================== --- projects/haf/trunk/maemo-launcher/launcher/comm_msg.h 2008-04-15 22:35:24 UTC (rev 15410) +++ projects/haf/trunk/maemo-launcher/launcher/comm_msg.h 2008-04-15 22:35:26 UTC (rev 15411) @@ -35,7 +35,7 @@ comm_msg_t *comm_msg_new(uint32_t size); bool comm_msg_destroy(comm_msg_t *msg); -bool comm_msg_grow(comm_msg_t *msg); +bool comm_msg_grow(comm_msg_t *msg, uint32_t need_size); bool comm_msg_reset(comm_msg_t *msg); bool comm_msg_send(int fd, comm_msg_t *msg);
- Previous message: [maemo-commits] r15410 - in projects/haf/trunk/maemo-launcher: . launcher
- Next message: [maemo-commits] r15412 - in projects/haf/trunk/maemo-launcher: . launcher
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]