--- lib/obex.c | 7 ++----- lib/obex_object.c | 14 ++++---------- 2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/lib/obex.c b/lib/obex.c index dcf0169..165fcb8 100644 --- a/lib/obex.c +++ b/lib/obex.c @@ -111,10 +111,9 @@ obex_t * CALLAPI OBEX_Init(int transport, obex_event_t eventcb, obex_return_val_if_fail(eventcb != NULL, NULL); - self = malloc(sizeof(*self)); + self = calloc(1, sizeof(*self)); if (self == NULL) return NULL; - memset(self, 0, sizeof(*self)); self->eventcb = eventcb; self->init_flags = flags; @@ -349,12 +348,10 @@ obex_t *CALLAPI OBEX_ServerAccept(obex_t *server, obex_event_t eventcb, return NULL; /* Allocate new instance */ - self = malloc(sizeof(*self)); + self = calloc(1, sizeof(*self)); if (self == NULL) return NULL; - memset(self, 0, sizeof(*self)); - /* Set callback and callback data as needed */ if (eventcb != NULL) self->eventcb = eventcb; diff --git a/lib/obex_object.c b/lib/obex_object.c index 1031bdc..cbfd1f1 100644 --- a/lib/obex_object.c +++ b/lib/obex_object.c @@ -42,13 +42,11 @@ */ obex_object_t *obex_object_new(void) { - obex_object_t *object = malloc(sizeof(*object)); + obex_object_t *object = calloc(1, sizeof(*object)); - if (object != NULL) { - memset(object, 0, sizeof(*object)); + if (object != NULL) obex_object_setrsp(object, OBEX_RSP_NOT_IMPLEMENTED, OBEX_RSP_NOT_IMPLEMENTED); - } return object; } @@ -181,12 +179,10 @@ int obex_object_addheader(obex_t *self, obex_object_t *object, uint8_t hi, maxlen = obex_object_getspace(self, object, flags); - element = malloc(sizeof(*element)); + element = calloc(1, sizeof(*element)); if (element == NULL) return -1; - memset(element, 0, sizeof(*element)); - element->hi = hi; element->flags = flags; @@ -900,7 +896,7 @@ static int obex_object_rcv_one_header(obex_t *self, uint8_t hi, DEBUG(4, "\n"); - element = malloc(sizeof(*element)); + element = calloc(1, sizeof(*element)); if (element == NULL) { DEBUG(1, "Cannot allocate memory\n"); if (hi == OBEX_HDR_BODY_END && object->rx_body) { @@ -911,8 +907,6 @@ static int obex_object_rcv_one_header(obex_t *self, uint8_t hi, return -1; } - memset(element, 0, sizeof(*element)); - if (hi == OBEX_HDR_BODY_END) hi = OBEX_HDR_BODY; -- 1.7.5.3 ------------------------------------------------------------------------------ Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 _______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users