/*
* call-seq:
* PGconn.escape( str )
*
* Returns a SQL-safe version of the String _str_.
* Unlike #quote, does not wrap the String in '...'.
*
* For more information, see
* PQescapestring[http://www.postgresql.org/docs/7.4/static/libpq-exec.html#LIBPQ-EXEC-ESCAPE-STRING]
* which is called internally by this method.
*/
static VALUE
pgconn_s_escape(self, obj)
VALUE self;
VALUE obj;
{
char *to;
long len;
VALUE ret;
Check_Type(obj, T_STRING);
to = ALLOC_N(char, RSTRING(obj)->len * 2);
len = PQescapeString(to, RSTRING(obj)->ptr, RSTRING(obj)->len);
ret = rb_str_new(to, len);
OBJ_INFECT(ret, obj);
free(to);
return ret;
}