Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2007 18:53:55 GMT
From:      Fredrik Lindberg <fli@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 119587 for review
Message-ID:  <200705091853.l49IrtnO038107@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119587

Change 119587 by fli@fli_genesis on 2007/05/09 18:52:54

	Add a function to expand the size of an existing buffer segment

Affected files ...

.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_buf.c#3 edit

Differences ...

==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_buf.c#3 (text+ko) ====

@@ -190,6 +190,26 @@
 		MDNS_BP_UNLOCK(bp);
 }
 
+int
+mdns_buf_expand(struct mdns_buf *buf, size_t len)
+{
+	char *p;
+
+	if (len == 0)
+		len = buf->b_sz * 2;
+	else if (len < buf->b_len)
+		return (-1);
+
+	p = realloc(buf->b_buf, len);
+	if (p == NULL)
+		return (-1);
+
+	buf->b_sz = len;
+	buf->b_buf = p;
+	buf->b_flags |= MDNS_BUF_TEMP;
+	return (0);
+}
+
 /*
  * Merge a chain of buffer segments into one continuous buffer
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705091853.l49IrtnO038107>