Code

src/liboping.c: Use sizeof(*ptr) instead of sizeof(type_t).
authorFlorian Forster <ff@octo.it>
Tue, 9 May 2017 06:40:33 +0000 (08:40 +0200)
committerFlorian Forster <ff@octo.it>
Tue, 9 May 2017 06:40:33 +0000 (08:40 +0200)
Also remove an unnecessary cast from void* to pingobj_t*.

src/liboping.c

index de82d5fde18544a4c3250c90267a4ace42d7b3f6..5a39633b6eab1d4e4cef7f104d5ae7c045948e5b 100644 (file)
@@ -1123,9 +1123,9 @@ pingobj_t *ping_construct (void)
 {
        pingobj_t *obj;
 
-       if ((obj = (pingobj_t *) malloc (sizeof (pingobj_t))) == NULL)
+       if ((obj = malloc (sizeof (*obj))) == NULL)
                return (NULL);
-       memset (obj, 0, sizeof (pingobj_t));
+       memset (obj, 0, sizeof (*obj));
 
        obj->timeout    = PING_DEF_TIMEOUT;
        obj->ttl        = PING_DEF_TTL;