Revert "Revert "* Added valgrind memory leak tests in testmem.sh for restconf""
This reverts commit a73d2bd242.
This commit is contained in:
parent
a73d2bd242
commit
83edd29678
29 changed files with 193 additions and 131 deletions
|
|
@ -66,6 +66,17 @@
|
|||
* @note If you change here, you must also change the structs below:
|
||||
* @see struct cli_handle
|
||||
* @see struct backend_handle
|
||||
* This is the internal definition of a "Clixon handle" which in its external
|
||||
* form is "clicon_handle" and is used in most Clixon API calls.
|
||||
* Some details:
|
||||
* 1) the internal structure contains a header (defined here) whereas higher
|
||||
* order libs (eg cli and backend) introduce more fields appended to this
|
||||
* struct.
|
||||
* 2) ch_options accessed via clicon_data() are clixon config options are
|
||||
* string values appearing in the XML configfile accessed with -f.
|
||||
* Alternatively, these could be accessed via clicon_conf_xml()
|
||||
* 3) ch_data accessed via clicon_data() is more general purpose for any data.
|
||||
* that is, not only strings. And has separate namespace from options.
|
||||
*/
|
||||
struct clicon_handle {
|
||||
int ch_magic; /* magic (HDR) */
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ hash_value(clicon_hash_t *hash,
|
|||
*
|
||||
* @param[in] hash Hash table
|
||||
* @param[in] key Variable name
|
||||
* @param[in] val Variable value
|
||||
* @param[in] val Variable value (pointer to)
|
||||
* @param[in] vlen Length of variable value
|
||||
* @retval variable New hash structure on success
|
||||
* @retval NULL Failure
|
||||
|
|
|
|||
|
|
@ -224,7 +224,6 @@ json_str_escape_cdata(cbuf *cb,
|
|||
char *str)
|
||||
{
|
||||
int retval = -1;
|
||||
char *snew = NULL;
|
||||
int i;
|
||||
int esc = 0; /* cdata escape */
|
||||
|
||||
|
|
@ -261,12 +260,8 @@ json_str_escape_cdata(cbuf *cb,
|
|||
cprintf(cb, "%c", str[i]);
|
||||
break;
|
||||
}
|
||||
if ((snew = strdup(cbuf_get(cb))) ==NULL){
|
||||
clicon_err(OE_XML, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
// done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@
|
|||
***** END LICENSE BLOCK *****
|
||||
|
||||
*
|
||||
* CLICON options
|
||||
* This file contains access functions for two types of clixon vars:
|
||||
* - options, ie string based variables from Clixon configuration files.
|
||||
* Accessed with clicon_options(h).
|
||||
* - data. Free-typed values for runtime getting and setting.
|
||||
* Accessed with clicon_data(h).
|
||||
* Consider splitting?
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "clixon_config.h" /* generated by config & autoconf */
|
||||
|
|
@ -359,6 +364,8 @@ clicon_option_str(clicon_handle h,
|
|||
* @param[in] h clicon_handle
|
||||
* @param[in] name option name
|
||||
* @param[in] val option value, must be null-terminated string
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clicon_option_str_set(clicon_handle h,
|
||||
|
|
@ -744,7 +751,7 @@ clicon_conf_xml(clicon_handle h)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*! Set YANG specification for Clixon system options and features
|
||||
/*! Set YANG specification for Clixon system options and features
|
||||
* ys must be a malloced pointer
|
||||
*/
|
||||
int
|
||||
|
|
@ -883,3 +890,35 @@ clicon_username_set(clicon_handle h,
|
|||
}
|
||||
|
||||
|
||||
/*! Get socket fd (ie backend server socket / restconf fcgx socket)
|
||||
* @param[in] h Clicon handle
|
||||
* @retval -1 No open socket
|
||||
* @retval s Socket
|
||||
*/
|
||||
int
|
||||
clicon_socket_get(clicon_handle h)
|
||||
{
|
||||
clicon_hash_t *cdat = clicon_data(h);
|
||||
void *p;
|
||||
|
||||
if ((p = hash_value(cdat, "socket", NULL)) == NULL)
|
||||
return -1;
|
||||
return *(int*)p;
|
||||
}
|
||||
|
||||
/*! Set socket fd (ie backend server socket / restconf fcgx socket)
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] s Open socket (or -1 to close)
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clicon_socket_set(clicon_handle h,
|
||||
int s)
|
||||
{
|
||||
clicon_hash_t *cdat = clicon_data(h);
|
||||
|
||||
if (s == -1)
|
||||
return hash_del(cdat, "socket");
|
||||
return hash_add(cdat, "socket", &s, sizeof(int))==NULL?-1:0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue