buffer_event: removed magic numbers for read/write buffer locations

Sun, 25 Nov 2007 17:40:47 -0500

author
Thomas Harning Jr <harningt@gmail.com>
date
Sun, 25 Nov 2007 17:40:47 -0500
changeset 53
e5ede009d0c5
parent 52
48def27d8ddd
child 54
bac1b4f541eb

buffer_event: removed magic numbers for read/write buffer locations

src/buffer_event.c file | annotate | diff | comparison | revisions
--- a/src/buffer_event.c	Tue Nov 20 18:03:53 2007 -0500
+++ b/src/buffer_event.c	Sun Nov 25 17:40:47 2007 -0500
@@ -9,6 +9,10 @@
 
 #define BUFFER_EVENT_MT "BUFFER_EVENT_MT"
 
+/* Locations of READ/WRITE buffers in the fenv */
+#define READ_BUFFER_LOCATION 4
+#define WRITE_BUFFER_LOCATION 5
+
 /* Obtains an le_bufferevent structure from a given index */
 static le_bufferevent* buffer_event_get(lua_State* L, int idx) {
 	return (le_bufferevent*)luaL_checkudata(L, idx, BUFFER_EVENT_MT);
@@ -86,9 +90,9 @@
 	lua_rawseti(L, -2, 3); // Err
 
 	event_buffer_push(L, ev->ev->input);
-	lua_rawseti(L, -2, 4);
+	lua_rawseti(L, -2, READ_BUFFER_LOCATION);
 	event_buffer_push(L, ev->ev->output);
-	lua_rawseti(L, -2, 5);
+	lua_rawseti(L, -2, WRITE_BUFFER_LOCATION);
 	lua_setfenv(L, -2);
 	ev->base = base;
 	return 1;
@@ -106,8 +110,8 @@
 		/* Also clear out the associated input/output event_buffers
 		 * since they would have already been freed.. */
 		lua_getfenv(L, 1);
-		lua_rawgeti(L, -1, 4);
-		lua_rawgeti(L, -2, 5);
+		lua_rawgeti(L, -1, READ_BUFFER_LOCATION);
+		lua_rawgeti(L, -2, WRITE_BUFFER_LOCATION);
 		read = event_buffer_check(L, -2);
 		write = event_buffer_check(L, -1);
 		/* Erase their knowledge of the buffer so that the GC won't try to double-free */

mercurial