X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstp.c;h=38885c07f666e472ce4691988863e7df7879e991;hb=a0bc29a541fc7dc6e20137d5558e2094d614e6ab;hp=87230bd9a27fd7c1979b38dc9982f5eaab45cc02;hpb=34e63086edddcae06d7c1a4fa84fec0861e50758;p=openvswitch diff --git a/lib/stp.c b/lib/stp.c index 87230bd9..38885c07 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ * applies to all modifications. */ #include "stp.h" +#include +#include #include #include #include @@ -214,7 +216,7 @@ stp_create(const char *name, stp_identifier bridge_id, struct stp *stp; struct stp_port *p; - stp = xcalloc(1, sizeof *stp); + stp = xzalloc(sizeof *stp); stp->name = xstrdup(name); stp->bridge_id = bridge_id; if (!(stp->bridge_id >> 48)) { @@ -256,7 +258,10 @@ stp_create(const char *name, stp_identifier bridge_id, void stp_destroy(struct stp *stp) { - free(stp); + if (stp) { + free(stp->name); + free(stp); + } } /* Runs 'stp' given that 'ms' milliseconds have passed. */