mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
Clarify pointer ownership decorators documentation
Use old char* in PGP functionas asked by Cyril
This commit is contained in:
parent
e406a1fb8b
commit
3f38d04680
@ -632,7 +632,7 @@ std::string PGPHandler::SaveCertificateToString(const RsPgpId& id,bool include_s
|
|||||||
|
|
||||||
bool PGPHandler::exportPublicKey(
|
bool PGPHandler::exportPublicKey(
|
||||||
const RsPgpId& id,
|
const RsPgpId& id,
|
||||||
rs_view_ptr<unsigned char>& mem_block, size_t& mem_size,
|
unsigned char*& mem_block, size_t& mem_size,
|
||||||
bool armoured, bool include_signatures ) const
|
bool armoured, bool include_signatures ) const
|
||||||
{
|
{
|
||||||
mem_block = nullptr; mem_size = 0; // clear just in case
|
mem_block = nullptr; mem_size = 0; // clear just in case
|
||||||
|
@ -107,8 +107,10 @@ public:
|
|||||||
bool LoadCertificateFromBinaryData(const unsigned char *bin_data,uint32_t bin_data_len, RsPgpId& gpg_id, std::string& error_string);
|
bool LoadCertificateFromBinaryData(const unsigned char *bin_data,uint32_t bin_data_len, RsPgpId& gpg_id, std::string& error_string);
|
||||||
|
|
||||||
std::string SaveCertificateToString(const RsPgpId& id,bool include_signatures) const ;
|
std::string SaveCertificateToString(const RsPgpId& id,bool include_signatures) const ;
|
||||||
|
|
||||||
|
/** The caller is in charge of freeing `mem` once finished */
|
||||||
bool exportPublicKey( const RsPgpId& id,
|
bool exportPublicKey( const RsPgpId& id,
|
||||||
rs_view_ptr<unsigned char>& mem,size_t& mem_size,
|
unsigned char*& mem, size_t& mem_size,
|
||||||
bool armoured, bool include_signatures) const;
|
bool armoured, bool include_signatures) const;
|
||||||
|
|
||||||
bool parseSignature(unsigned char *sign, unsigned int signlen,RsPgpId& issuer_id) ;
|
bool parseSignature(unsigned char *sign, unsigned int signlen,RsPgpId& issuer_id) ;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* libretroshare: retroshare core library *
|
* libretroshare: retroshare core library *
|
||||||
* *
|
* *
|
||||||
* Copyright 2012 Cyril Soler <csoler@users.sourceforge.net> *
|
* Copyright 2012 Cyril Soler <csoler@users.sourceforge.net> *
|
||||||
* Copyright 2019 Gioacchino Mazzurco <gio@altermundi.net> *
|
* Copyright 2019-2020 Gioacchino Mazzurco <gio@altermundi.net> *
|
||||||
* *
|
* *
|
||||||
* This program is free software: you can redistribute it and/or modify *
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
@ -89,19 +89,28 @@ bool rs_unique_cast(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark a pointer as non-owned aka you are not in charge of deleting it and
|
/** Mark a pointer as non-owned aka it must not be deleted/freed in that context.
|
||||||
* must not delete it.
|
* If a function take an `rs_view_ptr` as paramether it means that she will not
|
||||||
|
* own (aka free/delete) the passed memory, instead the caller is in charge of
|
||||||
|
* managing it. If a function return an `rs_view_ptr` it means the memory is
|
||||||
|
* managed internally and the caller should not call free/delete on it.
|
||||||
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
|
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
|
||||||
template<typename T> using rs_view_ptr = T*;
|
template<typename T> using rs_view_ptr = T*;
|
||||||
|
|
||||||
/** Mark a pointer as owned aka you are in charge of deletingonce finished
|
/** Mark a pointer as owned aka the receiving context is in charge of dealing
|
||||||
* dealing with it.
|
* with it by free/delete once finished.
|
||||||
|
* If a function take an `rs_owner_ptr` as paramether it means that she will own
|
||||||
|
* (aka free/delete when finished using it) the passed memory, instead the
|
||||||
|
* caller is NOT in charge of managing it.
|
||||||
|
* If a function return an `rs_owner_ptr` it means the memory is NOT managed
|
||||||
|
* internally and the caller should call free/delete on it once finished using
|
||||||
|
* it.
|
||||||
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
|
* @see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1408r0.pdf */
|
||||||
template<typename T> using rs_owner_ptr = T*;
|
template<typename T> using rs_owner_ptr = T*;
|
||||||
|
|
||||||
|
|
||||||
void *rs_malloc(size_t size) ;
|
void *rs_malloc(size_t size) ;
|
||||||
|
|
||||||
|
/** @deprecated use std::unique_ptr instead
|
||||||
// This is a scope guard to release the memory block when going of of the current scope.
|
// This is a scope guard to release the memory block when going of of the current scope.
|
||||||
// Can be very useful to auto-delete some memory on quit without the need to call free each time.
|
// Can be very useful to auto-delete some memory on quit without the need to call free each time.
|
||||||
//
|
//
|
||||||
@ -118,11 +127,11 @@ void *rs_malloc(size_t size) ;
|
|||||||
// [do something]
|
// [do something]
|
||||||
//
|
//
|
||||||
// } // mem gets freed automatically
|
// } // mem gets freed automatically
|
||||||
//
|
*/
|
||||||
class RsTemporaryMemory
|
class RsTemporaryMemory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsTemporaryMemory(size_t s)
|
explicit RsTemporaryMemory(size_t s)
|
||||||
{
|
{
|
||||||
_mem = (unsigned char *)rs_malloc(s) ;
|
_mem = (unsigned char *)rs_malloc(s) ;
|
||||||
|
|
||||||
@ -136,14 +145,7 @@ public:
|
|||||||
|
|
||||||
size_t size() const { return _size ; }
|
size_t size() const { return _size ; }
|
||||||
|
|
||||||
~RsTemporaryMemory()
|
~RsTemporaryMemory() { free(_mem); }
|
||||||
{
|
|
||||||
if(_mem != NULL)
|
|
||||||
{
|
|
||||||
free(_mem) ;
|
|
||||||
_mem = NULL ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char *_mem ;
|
unsigned char *_mem ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user