Update some comments to reflect reality.
authorGuy Harris <guy@alum.mit.edu>
Sun, 18 Jan 2015 21:02:15 +0000 (13:02 -0800)
committerGuy Harris <guy@alum.mit.edu>
Sun, 18 Jan 2015 21:02:40 +0000 (21:02 +0000)
Get rid of references to ep_ and se_ allocation in code that now uses
wmem allocation instead.

Fix API documentation of conversation_table.h routines to reflect that
as well - some APIs changed to pass wmem scopes.

Also, zbee_sec_key_hash() now takes the output buffer as an argument and
just returns it, and nobody actually uses the return value, so change it
to return void.

Change-Id: Ife1ec675a9322fd0f0be306a9d639ec17aad1c7a
Reviewed-on: https://code.wireshark.org/review/6636
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/addr_resolv.c
epan/conversation.c
epan/conversation_table.h
epan/dissectors/packet-bacapp.c
epan/dissectors/packet-dcerpc-nt.c
epan/dissectors/packet-dcm.c
epan/dissectors/packet-spdy.c
epan/dissectors/packet-zbee-aps.c
epan/dissectors/packet-zbee-security.c
ui/qt/packet_list.cpp

index a27e09a7601f34daf700d6392bc3a12905bddc4b..b7ff553aab209a6966be72c409f8a353075e65ab 100644 (file)
@@ -2908,8 +2908,6 @@ address_to_display(wmem_allocator_t *allocator, const address *addr)
     const gchar *result = solve_address_to_name(addr);
 
     if (result != NULL) {
-        /* unlike ep_address_to_display(), we can't assume the lifetime of the address' members
-           is safe, so we allocate and copy */
         str = wmem_strdup(allocator, result);
     }
     else if (addr->type == AT_NONE) {
index aa66996ef0f4d066c0780a0162df9f752a11a87b..859555187e36b8729d2fb58bddf65f06527a7be4 100644 (file)
@@ -466,7 +466,7 @@ free_data_list(gpointer value)
 {
        conversation_t *conv = (conversation_t *)value;
 
-       /* TODO: se_slist? */
+       /* TODO: file scoped wmem_list? There's no singly-linked wmem_ list */
        g_slist_free(conv->data_list);
 
        /* Not really necessary, but... */
@@ -482,7 +482,8 @@ conversation_cleanup(void)
 {
        /*  Clean up the hash tables, but only after freeing any proto_data
         *  that may be hanging off the conversations.
-        *  The conversation keys are se_ allocated so we don't have to clean them up.
+        *  The conversation keys are wmem-allocated with file scope so we
+        *  don't have to clean them up.
         */
        conversation_keys = NULL;
        if (conversation_hashtable_exact != NULL) {
index 61b9ce7f394876c3cf9e123f7387844b1cdef314..5c5699dad5710fa45c97a7b6bdae64242968f274 100644 (file)
@@ -253,18 +253,20 @@ WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
 
 /** Get the string representation of an address.
  *
+ * @param allocator The wmem allocator to use when allocating the string
  * @param addr The address.
  * @param resolve_names Enable name resolution.
- * @return An ep_allocated string representing the address.
+ * @return A string representing the address.
  */
 WS_DLL_PUBLIC const char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
 
 /** Get the string representation of a port.
  *
+ * @param allocator The wmem allocator to use when allocating the string
  * @param port The port number.
  * @param ptype The port type.
  * @param resolve_names Enable name resolution.
- * @return An ep_allocated string representing the port.
+ * @return A string representing the port.
  */
 WS_DLL_PUBLIC const char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names);
 
@@ -279,7 +281,8 @@ WS_DLL_PUBLIC const char *get_conversation_filter(conv_item_t *conv_item, conv_d
 /** Get a display filter for the given hostlist.
  *
  * @param host The hostlist.
- * @return An ep_allocated string representing the conversation.
+ * @return A string, allocated using the wmem NULL allocator,
+ * representing the conversation.
  */
 WS_DLL_PUBLIC const char *get_hostlist_filter(hostlist_talker_t *host);
 
index bc4dd2e47921e476d2d8a66f263d6f2be6e7c12c..1058edf70bf7990e5b3d66b22022fbb36a9a0261 100644 (file)
@@ -5093,7 +5093,7 @@ register_bacapp_stat_trees(void)
         bacapp_stats_tree_instanceid, bacapp_instanceid_stats_tree_init, NULL);
 }
 
-/* 'data' must be ep_ allocated */
+/* 'data' must be allocated with wmem packet scope */
 static gint
 updateBacnetInfoValue(gint whichval, const gchar *data)
 {
index 36518c4462f2f57f94e869c0c13e0ea0de02c9c2..d8a95fa97df16c9bd4b9b0326b5e9b11bee6a67f 100644 (file)
@@ -873,8 +873,8 @@ static void init_pol_hash(void)
        /* Initialise hash table */
 
        if (pol_hash) {
-               /*  Everything in the table is se_ allocated so there's no
-                *  need to go through and free it all.
+               /*  Everything in the table is allocated with wmem file
+                *  scope so there's no need to go through and free it all.
                 */
                g_hash_table_destroy(pol_hash);
        }
index fa57050e7e82aa2abbac6016b3f21fcfd4924b1c..3b69ed6759e46b4e1ca409662d7c82ce0afc13e4 100644 (file)
  * - Read private tags from configuration and parse in capture
  * - dissect_dcm_heuristic() to return proper data type
  *
+ * September 2013 - Pascal Quantin
+ *
+ * - Replace all ep_ and se_ allocation with wmem_ allocations
+ *
  * February 2013 - Stefan Allers
  *
  * - Support for dissection of Extended Negotiation (Query/Retrieve
@@ -6099,7 +6103,7 @@ dissect_dcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
     gboolean is_sequence = FALSE;           /* True for Sequence Tags */
     gboolean is_item = FALSE;               /* True for Sequence Item Tags */
 
-    *tag_description = NULL;                /* Reset description. It's ep_ memory, so not really bad*/
+    *tag_description = NULL;                /* Reset description. It's wmem packet scope memory, so not really bad*/
 
     tag_value = (gchar *)wmem_alloc0(wmem_packet_scope(), MAX_BUF_LEN);
 
@@ -6351,7 +6355,7 @@ dissect_dcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
         gboolean local_end_of_seq_or_item = FALSE;
         gboolean is_first_desc = TRUE;
 
-        const gchar *item_description = NULL;       /* Will be allocated as ep_ memory in dissect_dcm_tag() */
+        const gchar *item_description = NULL;       /* Will be allocated as wmem packet scope memory in dissect_dcm_tag() */
 
         if (vl == 0xFFFFFFFF) {
             /* Undefined length */
index b9a0277dfa4ab10b876c2d75727cf89dbe155ca9..6a0a63dfe36b2de612502650959b540ab942de79 100644 (file)
@@ -948,7 +948,7 @@ body_dissected:
  * Performs header decompression.
  *
  * The returned buffer is automatically scoped to the lifetime of the capture
- * (via se_memdup()).
+ * (via wmem_memdup() with file scope).
  */
 #define DECOMPRESS_BUFSIZE   16384
 
index b28393ac7f88806ce263e7f653482c9349120909..cabd99771c0e2ae79d4e20c8c818d330c44e2f6e 100644 (file)
@@ -1290,6 +1290,10 @@ dissect_zbee_aps_transport_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
             /* Create an empty key ring for this pan. Use g_malloc0() because we must free
              * GSLists after a capture is closed and wireshark frees seasonal memory
              * with se_free_all() before calling the registered init routine.
+             *
+             * XXX - we don't use seasonal memory any more, and libwireshark
+             * just does wmem_enter_file_scope() before calling registered init
+             * routines; does this still apply?
              */
             nwk_keyring = (GSList **)g_malloc0(sizeof(GSList*));
             g_hash_table_insert(zbee_table_nwk_keyring,
index ea2fd1e3bc3a882d3c5cfdca08e771946302fd5a..c2312a1b1f13ba6a6a644e0b9eaff248903a5bde 100644 (file)
@@ -47,7 +47,7 @@
 
 /* Helper Functions */
 #ifdef HAVE_LIBGCRYPT
-static guint8 *    zbee_sec_key_hash(guint8 *, guint8, guint8 *);
+static void        zbee_sec_key_hash(guint8 *, guint8, guint8 *);
 static void        zbee_sec_make_nonce (zbee_security_packet *, guint8 *);
 static gboolean    zbee_sec_decrypt_payload(zbee_security_packet *, const gchar *, const gchar, guint8 *,
         guint, guint, guint8 *);
@@ -1213,18 +1213,15 @@ zbee_sec_hash(guint8 *input, guint input_len, guint8 *output)
  *          ipad = 0x36 repeated.
  *          opad = 0x5c repeated.
  *          H() = ZigBee Cryptographic Hash (B.1.3 and B.6).
- *
- *      The output of this function is an ep_alloced buffer containing
- *      the key-hashed output, and is garaunteed never to return NULL.
  *  PARAMETERS
- *      guint8  *key    - ZigBee Security Key (must be ZBEE_SEC_CONST_KEYSIZE) in length.
- *      guint8  input   - ZigBee CCM* Nonce (must be ZBEE_SEC_CONST_NONCE_LEN) in length.
- *      packet_info *pinfo  - pointer to packet information fields
+ *      guint8  *key      - ZigBee Security Key (must be ZBEE_SEC_CONST_KEYSIZE) in length.
+ *      guint8  input     - ZigBee CCM* Nonce (must be ZBEE_SEC_CONST_NONCE_LEN) in length.
+ *      guint8  *hash_out - buffer into which the key-hashed output is placed
  *  RETURNS
- *      guint8*
+ *      void
  *---------------------------------------------------------------
  */
-static guint8 *
+static void
 zbee_sec_key_hash(guint8 *key, guint8 input, guint8 *hash_out)
 {
     guint8              hash_in[2*ZBEE_SEC_CONST_BLOCKSIZE];
@@ -1244,7 +1241,6 @@ zbee_sec_key_hash(guint8 *key, guint8 input, guint8 *hash_out)
     zbee_sec_hash(hash_out, ZBEE_SEC_CONST_BLOCKSIZE+1, hash_in+ZBEE_SEC_CONST_BLOCKSIZE);
     /* Hash the contents of hash_in to get the final result. */
     zbee_sec_hash(hash_in, 2*ZBEE_SEC_CONST_BLOCKSIZE, hash_out);
-    return hash_out;
 } /* zbee_sec_key_hash */
 #else   /* HAVE_LIBGCRYPT */
 gboolean
index 43aab835a8ccd8775ec0aeac6e4c8adedb488924..d3a4af5b3582defdfda841631ec52cc321bd1607 100644 (file)
@@ -739,7 +739,6 @@ QString &PacketList::getFilterFromRowAndColumn()
              */
             if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 &&
                 strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) {
-                /* leak a little but safer than ep_ here */
                 if (cap_file_->cinfo.col_fmt[ctx_column_] == COL_CUSTOM) {
                     header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.col_custom_field[ctx_column_]);
                     if (hfi->parent == -1) {