Change allocate/initialize for LmConnection to not create the LM object in allocate
authorMikael Hallendal <micke@imendio.com>
Wed, 09 Apr 2008 22:24:37 +0200
changeset 365 64b1c1c32d56
parent 364 71e6639a924d
child 366 4e9e64a468f3
Change allocate/initialize for LmConnection to not create the LM object in allocate
bindings/ruby/rblm-connection.c
--- a/bindings/ruby/rblm-connection.c	Wed Apr 09 22:12:34 2008 +0200
+++ b/bindings/ruby/rblm-connection.c	Wed Apr 09 22:24:37 2008 +0200
@@ -20,11 +20,6 @@
 }
 
 void
-conn_mark (LmConnection *self)
-{
-}
-
-void
 conn_free (LmConnection *self)
 {
 	lm_connection_unref (self);
@@ -33,21 +28,28 @@
 VALUE
 conn_allocate(VALUE klass)
 {
-	LmConnection *conn = lm_connection_new (NULL);
-
-	return Data_Wrap_Struct (klass, conn_mark, conn_free, conn);
+	return Data_Wrap_Struct (klass, NULL, conn_free, NULL);
 }
 
 VALUE
 conn_initialize (VALUE self, VALUE server, VALUE context)
 {
 	LmConnection *conn;
-
-	Data_Get_Struct (self, LmConnection, conn);
+	char         *srv_str = NULL;
 
-	conn_set_server (self, server);
+	if (NIL_P (context)) {
+		GMainContext *ctx = NULL;
+		/* FIXME: read out the context from context */
+		conn = lm_connection_new_with_context (NULL, ctx);
+	} else {
+		conn = lm_connection_new (NULL);
+	}
 
-	/* Set context */
+	DATA_PTR (self) = conn;
+
+	if (!NIL_P (server)) {
+		conn_set_server (self, server);
+	}
 
 	return self;
 }