Ron Peterson <[EMAIL PROTECTED]> writes:
> char*
> tp2cp_palloc( char* stringp, const text* textp ) {
> int len;
> len = VARSIZE(textp) - VARHDRSZ;
> stringp = (char*)palloc( len + 1 );
> if( ! memcpy( stringp, VARDATA(textp), len ) ) { return NULL; }
> if( ! memset( stringp + len, '\0', 1 ) ) { return NULL; }
> return stringp;
> }
That's simply bizarre coding style. stringp should be a local in
tp2cp_palloc, not a passed parameter that you ignore the value of.
> Which I call like
> otherfunc() {
> char* rd;
> if( ! tp2cp_palloc( rd, rand_dev ) )
> ...
The above does not cause rd to become set in otherfunc().
Had you been using a reasonable set of compiler flags, the compiler
would have warned you that rd was uninitialized in otherfunc().
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly