Hello Magnus,
As far as I know until now the following convention was used in the Net-SNMP
source tree:
* Character strings owned by a data structure and that have to be freed when
the data structure itself is deallocated are declared as *char **.
* Character strings not owned by a data structure and that must not be freed
when the data structure itself is deallocated are declared as *const char**.
You are changing this convention.
Furthermore, this particular patch has the disadvantage that the compiler
will no longer issue a warning when a coder forgets to strdup() a string
before assigning it to subtree_context_cache.context_name. Consider e.g. the
following code:
netsnmp_subtree *
add_subtree(netsnmp_subtree *new_tree, const char *context_name)
{
subtree_context_cache *ptr = SNMP_MALLOC_TYPEDEF(subtree_context_cache);
if (!context_name) {
context_name = "";
}
if (!ptr) {
return NULL;
}
DEBUGMSGTL(("subtree", "adding subtree for context: \"%s\"\n",
context_name));
ptr->next = context_subtrees;
ptr->first_subtree = new_tree;
ptr->context_name = strdup(context_name);
context_subtrees = ptr;
return ptr->first_subtree;
}
With the old definition of subtree_context_cache, the compiler would have
issued a warning when the context_name argument would have been assigned to
ptr->context_name without having called strdup(). With the new definition of
subtree_context_cache, the compiler won't issue a warning for such an
erroneous assignment.
Bart.
---------- Forwarded message ----------
From: <[email protected]>
Date: Sun, Jan 24, 2010 at 3:43 PM
Subject: SF.net SVN: net-snmp:[18053] trunk/net-snmp
To: [email protected]
Revision: 18053
http://net-snmp.svn.sourceforge.net/net-snmp/?rev=18053&view=rev
Author: magfr
Date: 2010-01-24 14:43:57 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
NEWS: snmpd: Made subtree_context_cache::context_name a const char*.
Modified Paths:
--------------
trunk/net-snmp/agent/agent_registry.c
trunk/net-snmp/include/net-snmp/agent/agent_registry.h
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders