1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//------------------------------------------------------------------------------
// LAGraph_Realloc: wrapper for realloc
//------------------------------------------------------------------------------
// LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
// SPDX-License-Identifier: BSD-2-Clause
//
// For additional details (including references to third party source code and
// other files) see the LICENSE file or contact permission@sei.cmu.edu. See
// Contributors.txt for a full list of contributors. Created, in part, with
// funding and support from the U.S. Government (see Acknowledgments.txt file).
// DM22-0790
// Contributed by Timothy A. Davis, Texas A&M University
//------------------------------------------------------------------------------
// If p is non-NULL on input, it points to a previously allocated object of
// size at least nitems_old * size_of_item. The object is reallocated to be of
// size at least nitems_new * size_of_item. If p is NULL on input, then a new
// object of that size is allocated. On success, a pointer to the new object
// is returned, and ok is returned as true. If the allocation fails, ok is set
// to false and a pointer to the old (unmodified) object is returned.
// Usage:
// int status = LAGraph_Realloc (&p, nitems_new, nitems_old, size_of_item, msg)
// if (status == GrB_SUCCESS)
// {
// p points to a block of at least nitems_new*size_of_item bytes and
// the first part, of size min(nitems_new,nitems_old)*size_of_item,
// has the same content as the old memory block if it was present.
// }
// else
// {
// p points to the old block, unchanged. This case never occurs if
// nitems_new < nitems_old.
// }
int