/*
 * call-seq:
 *    PGconn.escape( str )
 *
 * Returns a SQL-safe version of the String _str_. Unlike #quote, does not wrap the String in '...'.
 */
static VALUE
pgconn_s_escape(self, string)
    VALUE self;
    VALUE string;
{
    char* escaped;
    int size;
    VALUE result;

    Check_Type(string, T_STRING);
    
    escaped = ALLOCA_N(char, RSTRING(string)->len * 2 + 1);
    size = PQescapeString(escaped, RSTRING(string)->ptr, RSTRING(string)->len);
    result = rb_str_new(escaped, size);
    OBJ_INFECT(result, string);
    return result;
}