MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / GB_hyper_realloc

Function GB_hyper_realloc

deps/GraphBLAS/Source/GB_hyper_realloc.c:17–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "GB_unused.h"
16
17GrB_Info GB_hyper_realloc
18(
19 GrB_Matrix A, // matrix with hyperlist to reallocate
20 int64_t plen_new, // new size of A->p and A->h
21 GB_Context Context
22)
23{
24
25 //--------------------------------------------------------------------------
26 // check inputs
27 //--------------------------------------------------------------------------
28
29 ASSERT (A != NULL) ;
30 ASSERT (GB_ZOMBIES_OK (A)) ; // pattern not accessed
31 ASSERT (GB_JUMBLED_OK (A)) ;
32 ASSERT (GB_PENDING_OK (A)) ;
33
34 //--------------------------------------------------------------------------
35 // reallocate the hyperlist
36 //--------------------------------------------------------------------------
37
38 if (GB_IS_HYPERSPARSE (A))
39 {
40 ASSERT (!A->p_shallow) ;
41 ASSERT (!A->h_shallow) ;
42
43 // old size of A->p and A->h
44 int64_t plen_old = A->plen ;
45 plen_new = GB_IMAX (1, plen_new) ;
46
47 // change the size of A->h and A->p
48 bool ok1 = true, ok2 = true ;
49 GB_REALLOC (A->p, plen_new+1, int64_t, &(A->p_size), &ok1, Context) ;
50 GB_REALLOC (A->h, plen_new, int64_t, &(A->h_size), &ok2, Context) ;
51 bool ok = ok1 && ok2 ;
52
53 // always succeeds if the space shrinks
54 ASSERT (GB_IMPLIES (plen_new <= plen_old, ok)) ;
55
56 if (!ok)
57 {
58 // out of memory
59 GB_phybix_free (A) ;
60 return (GrB_OUT_OF_MEMORY) ;
61 }
62
63 // size of A->p and A->h has been changed
64 A->plen = plen_new ;
65 }
66
67 //--------------------------------------------------------------------------
68 // return result
69 //--------------------------------------------------------------------------
70
71 return (GrB_SUCCESS) ;
72}
73

Callers 2

GB_jappendFunction · 0.85
GB_resizeFunction · 0.85

Calls 1

GB_phybix_freeFunction · 0.85

Tested by

no test coverage detected