r23779: Change from v2 or later to v3 or later.
[samba.git] / source3 / registry / reg_perfcount.c
index 26d640c87cab71ddde22c377cae1e744b78fd644..66e01c7ba8e3ac49302fed16379228bfab22a6ca 100644 (file)
@@ -7,7 +7,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -31,6 +31,8 @@
 #define NAMES_DB       "names.tdb"
 #define DATA_DB                "data.tdb"
 
+PERF_OBJECT_TYPE *_reg_perfcount_find_obj(PERF_DATA_BLOCK *block, int objind);
+
 /*********************************************************************
 *********************************************************************/
 
@@ -96,8 +98,7 @@ uint32 reg_perfcount_get_base_index(void)
           even_num+1 perf_counter<even_num>_help
           and so on.
           So last_counter becomes num_counters*2, and last_help will be last_counter+1 */
-       kbuf.dptr = key;
-       kbuf.dsize = strlen(key);
+       kbuf = string_tdb_data(key);
        dbuf = tdb_fetch(names, kbuf);
        if(dbuf.dptr == NULL)
        {
@@ -164,8 +165,7 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
 
        memset(temp, 0, sizeof(temp));
        snprintf(temp, sizeof(temp), "%d", keyval);
-       kbuf.dptr = temp;
-       kbuf.dsize = strlen(temp);
+       kbuf = string_tdb_data(temp);
        dbuf = tdb_fetch(tdb, kbuf);
        if(dbuf.dptr == NULL)
        {
@@ -182,7 +182,7 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
                buffer_size = 0;
                return buffer_size;
        }
-       init_unistr2(&name_index, kbuf.dptr, UNI_STR_TERMINATE);
+       init_unistr2(&name_index, (const char *)kbuf.dptr, UNI_STR_TERMINATE);
        memcpy(buf1+buffer_size, (char *)name_index.buffer, working_size);
        buffer_size += working_size;
        /* Now encode the actual name */
@@ -307,8 +307,7 @@ static void _reg_perfcount_make_key(TDB_DATA *key,
        else 
                snprintf(buf, buflen, "%d", key_part1);
 
-       key->dptr = buf;
-       key->dsize = strlen(buf);
+       *key = string_tdb_data(buf);
 
        return;
 }
@@ -359,6 +358,7 @@ static uint32 _reg_perfcount_get_numinst(int objInd, TDB_CONTEXT *names)
     
        memset(buf, 0, PERFCOUNT_MAX_LEN);
        memcpy(buf, data.dptr, data.dsize);
+       SAFE_FREE(data.dptr);
        return (uint32)atoi(buf);
 }
 
@@ -1029,7 +1029,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(PERF_DATA_BLOCK *block, prs_s
 uint32 reg_perfcount_get_perf_data_block(uint32 base_index, 
                                         prs_struct *ps, 
                                         PERF_DATA_BLOCK *block,
-                                        char *object_ids)
+                                        const char *object_ids)
 {
        uint32 buffer_size = 0;
        const char *fname = counters_directory( NAMES_DB );
@@ -1322,7 +1322,7 @@ static BOOL _reg_perfcount_marshall_hkpd(prs_struct *ps, PERF_DATA_BLOCK block)
 /*********************************************************************
 *********************************************************************/
 
-WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, char *object_ids)
+WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids)
 {
        /*
         * For a detailed description of the layout of this structure,