shithub: choc

Download patch

ref: f65633b5f50be8581ec2de7c06ca9a225d48b82a
parent: 6b56827d7672aa19f7ce32debb8b207e0bfeb4fb
author: Simon Howard <[email protected]>
date: Mon Jan 2 16:02:16 EST 2006

Change AddrToString function to use an internal static buffer, for
ease of use.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 249

--- a/src/net_io.c
+++ b/src/net_io.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_io.c 229 2005-10-30 19:56:15Z fraggle $
+// $Id: net_io.c 249 2006-01-02 21:02:16Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.2  2006/01/02 21:02:16  fraggle
+// Change AddrToString function to use an internal static buffer, for
+// ease of use.
+//
 // Revision 1.1  2005/10/30 19:56:15  fraggle
 // Add foundation code for the new networking system
 //
@@ -109,9 +113,16 @@
     return false;
 }
 
-void NET_AddrToString(net_addr_t *addr, char *buffer, int buffer_len)
+// Note: this prints into a static buffer, calling again overwrites
+// the first result
+
+char *NET_AddrToString(net_addr_t *addr)
 {
-    addr->module->AddrToString(addr, buffer, buffer_len);
+    static char buf[128];
+
+    addr->module->AddrToString(addr, buf, sizeof(buf) - 1);
+
+    return buf;
 }
 
 void NET_FreeAddress(net_addr_t *addr)
--- a/src/net_io.h
+++ b/src/net_io.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_io.h 229 2005-10-30 19:56:15Z fraggle $
+// $Id: net_io.h 249 2006-01-02 21:02:16Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.2  2006/01/02 21:02:16  fraggle
+// Change AddrToString function to use an internal static buffer, for
+// ease of use.
+//
 // Revision 1.1  2005/10/30 19:56:15  fraggle
 // Add foundation code for the new networking system
 //
@@ -40,7 +44,7 @@
 void NET_SendPacket(net_addr_t *addr, net_packet_t *packet);
 boolean NET_RecvPacket(net_context_t *context, net_addr_t **addr, 
                        net_packet_t **packet);
-void NET_AddrToString(net_addr_t *addr, char *buffer, int buffer_len);
+char *NET_AddrToString(net_addr_t *addr);
 void NET_FreeAddress(net_addr_t *addr);
 net_addr_t *NET_ResolveAddress(net_context_t *context, char *address);