    /*
     * call-seq:
     *  parse_memory(data)
     *
     * Parse the XML stored in memory in +data+
     */
    static VALUE parse_memory(VALUE klass, VALUE data)
    {
      xmlParserCtxtPtr ctxt;

      if(NIL_P(data)) rb_raise(rb_eArgError, "data cannot be nil");
      if(!(int)RSTRING_LEN(data))
        rb_raise(rb_eRuntimeError, "data cannot be empty");

      ctxt = xmlCreateMemoryParserCtxt(
          StringValuePtr(data),
          (int)RSTRING_LEN(data)
      );

      return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
    }