Is BUF_MEM in BIO_s_mem automatically freed?
Hi, The doc [*] says: If the BIO_CLOSE flag is set when a memory BIO is freed then the underlying BUF_MEM structure is also freed. The only place to set such a BIO_CLOSE flag is in the c argument in function: BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) So, must I understand that, in case I don't set a custom buffer (this is, I do not call to BIO_set_mem_buf(), then the internal buffer of my BIO will be freed when I call free(my_bio)? Thanks a lot. [*] http://linux.die.net/man/3/bio_s_mem -- Iñaki Baz Castillo i...@aliax.net __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: Is BUF_MEM in BIO_s_mem automatically freed?
On Sat, Jul 19, 2014, Iaki Baz Castillo wrote: Hi, The doc [*] says: If the BIO_CLOSE flag is set when a memory BIO is freed then the underlying BUF_MEM structure is also freed. The only place to set such a BIO_CLOSE flag is in the c argument in function: BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) It can also be set with BIO_set_close(). So, must I understand that, in case I don't set a custom buffer (this is, I do not call to BIO_set_mem_buf(), then the internal buffer of my BIO will be freed when I call free(my_bio)? And if you don't call BIO_set_close() with BIO_NOCLOSE, yes. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: Is BUF_MEM in BIO_s_mem automatically freed?
On 19/07/14 15:53, Iñaki Baz Castillo wrote: Hi, The doc [*] says: If the BIO_CLOSE flag is set when a memory BIO is freed then the underlying BUF_MEM structure is also freed. The only place to set such a BIO_CLOSE flag is in the c argument in function: BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) You can also call BIO_set_close. So, must I understand that, in case I don't set a custom buffer (this is, I do not call to BIO_set_mem_buf(), then the internal buffer of my BIO will be freed when I call free(my_bio)? You should not call free directly. Instead you should use BIO_free. As long as you do that and as long as you haven't called BIO_set_close with BIO_NOCLOSE (or BIO_set_mem_buf as above), then the internal buffer will be freed. Matt __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Re: Is BUF_MEM in BIO_s_mem automatically freed?
2014-07-19 17:53 GMT+02:00 Matt Caswell m...@openssl.org: So, must I understand that, in case I don't set a custom buffer (this is, I do not call to BIO_set_mem_buf(), then the internal buffer of my BIO will be freed when I call free(my_bio)? You should not call free directly. Instead you should use BIO_free. Yes sorry, it was a typo in my text. As long as you do that and as long as you haven't called BIO_set_close with BIO_NOCLOSE (or BIO_set_mem_buf as above), then the internal buffer will be freed. Thanks to both. It is clear now. Thanks! -- Iñaki Baz Castillo i...@aliax.net __ OpenSSL Project http://www.openssl.org User Support Mailing Listopenssl-users@openssl.org Automated List Manager majord...@openssl.org
Releasing memory, BUF_MEM*
Hello, I have initialized a memory BIO to have certain content. My question is: -Do I have to release the BUF_MEM pointer bm? -Or is rbio using bm, thus loosing its data if I release the memory? And naturally, bm is destroyed upon destroying the rbio object. Thank you for your time. A simplified code is included below: BIO* rbio; BUF_MEM* bm = BUF_MEM_new();rbio = BIO_new(BIO_s_mem());BUF_MEM_grow(bm, len;memcpy(bm-data, buf, len);BIO_set_mem_buf(rbio, bm, 0); Regards, Ola Flygare Developer Lenco Software as Fredensborgveien 6 N-0177 OSLO Tel +47 22 20 19 09 Mobile +47 98 03 36 87
BUF_MEM...
Hello! I've got a question about buf_mem The BIO_get_mem_ptr, Does it make a copy of the bytes in the byte array where is used? That is, Is there any function to free a BUF_MEM ? This is my source code BIO *bio=BIO_new(BIO_s_mem()); BUF_MEM *buf_mem=NULL; BIO_get_mem_ptr(bio,buf_mem); unsigned char *bytes=buf_mem-data; int length=buf_mem-length Must I to free the BUF_MEM or only the BIO? Thanks in advance for your answer, Regards, Antonio. __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]