2 * constructors.c : Constructors for various data structures.
4 * ====================================================================
5 * Copyright (c) 2005-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #include <apr_pools.h>
20 #include <apr_strings.h>
22 #include "svn_types.h"
23 #include "svn_props.h"
24 #include "svn_string.h"
28 svn_create_commit_info(apr_pool_t
*pool
)
30 svn_commit_info_t
*commit_info
31 = apr_pcalloc(pool
, sizeof(*commit_info
));
33 commit_info
->revision
= SVN_INVALID_REVNUM
;
34 /* All other fields were initialized to NULL above. */
40 svn_commit_info_dup(const svn_commit_info_t
*src_commit_info
,
43 svn_commit_info_t
*dst_commit_info
= svn_create_commit_info(pool
);
45 dst_commit_info
->date
= src_commit_info
->date
46 ? apr_pstrdup(pool
, src_commit_info
->date
) : NULL
;
47 dst_commit_info
->author
= src_commit_info
->author
48 ? apr_pstrdup(pool
, src_commit_info
->author
) : NULL
;
49 dst_commit_info
->revision
= src_commit_info
->revision
;
50 dst_commit_info
->post_commit_err
= src_commit_info
->post_commit_err
51 ? apr_pstrdup(pool
, src_commit_info
->post_commit_err
) : NULL
;
53 return dst_commit_info
;
56 svn_log_changed_path_t
*
57 svn_log_changed_path_dup(const svn_log_changed_path_t
*changed_path
,
60 svn_log_changed_path_t
*new_changed_path
61 = apr_palloc(pool
, sizeof(*new_changed_path
));
63 *new_changed_path
= *changed_path
;
65 if (new_changed_path
->copyfrom_path
)
66 new_changed_path
->copyfrom_path
=
67 apr_pstrdup(pool
, new_changed_path
->copyfrom_path
);
69 return new_changed_path
;
73 * Reallocate the members of PROP using POOL.
76 svn_prop__members_dup(svn_prop_t
*prop
, apr_pool_t
*pool
)
79 prop
->name
= apr_pstrdup(pool
, prop
->name
);
81 prop
->value
= svn_string_dup(prop
->value
, pool
);
85 svn_prop_dup(const svn_prop_t
*prop
, apr_pool_t
*pool
)
87 svn_prop_t
*new_prop
= apr_palloc(pool
, sizeof(*new_prop
));
91 svn_prop__members_dup(new_prop
, pool
);
97 svn_prop_array_dup(const apr_array_header_t
*array
, apr_pool_t
*pool
)
100 apr_array_header_t
*new_array
= apr_array_copy(pool
, array
);
101 for (i
= 0; i
< new_array
->nelts
; ++i
)
103 svn_prop_t
*elt
= &APR_ARRAY_IDX(new_array
, i
, svn_prop_t
);
104 svn_prop__members_dup(elt
, pool
);
110 svn_prop_hash_to_array(apr_hash_t
*hash
, apr_pool_t
*pool
)
112 apr_hash_index_t
*hi
;
113 apr_array_header_t
*array
= apr_array_make(pool
, apr_hash_count(hash
),
116 for (hi
= apr_hash_first(pool
, hash
); hi
; hi
= apr_hash_next(hi
))
122 apr_hash_this(hi
, &key
, NULL
, &val
);
125 APR_ARRAY_PUSH(array
, svn_prop_t
) = prop
;
132 svn_dirent_dup(const svn_dirent_t
*dirent
,
135 svn_dirent_t
*new_dirent
= apr_palloc(pool
, sizeof(*new_dirent
));
137 *new_dirent
= *dirent
;
139 new_dirent
->last_author
= apr_pstrdup(pool
, dirent
->last_author
);
145 svn_log_entry_create(apr_pool_t
*pool
)
147 svn_log_entry_t
*log_entry
= apr_pcalloc(pool
, sizeof(*log_entry
));
152 svn_location_segment_t
*
153 svn_location_segment_dup(svn_location_segment_t
*segment
,
156 svn_location_segment_t
*new_segment
=
157 apr_pcalloc(pool
, sizeof(*new_segment
));
158 *new_segment
= *segment
;
160 new_segment
->path
= apr_pstrdup(pool
, segment
->path
);