Fossil SCM
Enhance the graph generator so that it uses less memory and so that it is not limited to a fixed number of parents (10) for each node.
Commit
5ee80c545dbb6b06032d946c33b3e28e9044cbe8
Parent
d5729c31b55eaeb…
1 file changed
+6
-4
+6
-4
| --- src/graph.c | ||
| +++ src/graph.c | ||
| @@ -21,11 +21,10 @@ | ||
| 21 | 21 | #include "graph.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | 24 | #if INTERFACE |
| 25 | 25 | |
| 26 | -#define GR_MAX_PARENT 10 /* Max number of parents for any one node */ | |
| 27 | 26 | #define GR_MAX_RAIL 32 /* Max number of "rails" to display */ |
| 28 | 27 | |
| 29 | 28 | /* The graph appears vertically beside a timeline. Each row in the |
| 30 | 29 | ** timeline corresponds to a row in the graph. GraphRow.idx is 0 for |
| 31 | 30 | ** the top-most row and increases moving down. Hence (in the absence of |
| @@ -32,11 +31,11 @@ | ||
| 32 | 31 | ** time skew) parents have a larger index than their children. |
| 33 | 32 | */ |
| 34 | 33 | struct GraphRow { |
| 35 | 34 | int rid; /* The rid for the check-in */ |
| 36 | 35 | i8 nParent; /* Number of parents */ |
| 37 | - int aParent[GR_MAX_PARENT]; /* Array of parents. 0 element is primary .*/ | |
| 36 | + int *aParent; /* Array of parents. 0 element is primary .*/ | |
| 38 | 37 | char *zBranch; /* Branch name */ |
| 39 | 38 | char *zBgClr; /* Background Color */ |
| 40 | 39 | |
| 41 | 40 | GraphRow *pNext; /* Next row down in the list of all rows */ |
| 42 | 41 | GraphRow *pPrev; /* Previous row */ |
| @@ -167,14 +166,17 @@ | ||
| 167 | 166 | int *aParent, /* Array of parents */ |
| 168 | 167 | const char *zBranch, /* Branch for this check-in */ |
| 169 | 168 | const char *zBgClr /* Background color. NULL or "" for white. */ |
| 170 | 169 | ){ |
| 171 | 170 | GraphRow *pRow; |
| 171 | + int nByte; | |
| 172 | 172 | |
| 173 | 173 | if( p->nErr ) return 0; |
| 174 | - if( nParent>GR_MAX_PARENT ){ p->nErr++; return 0; } | |
| 175 | - pRow = (GraphRow*)safeMalloc( sizeof(GraphRow) ); | |
| 174 | + nByte = sizeof(GraphRow); | |
| 175 | + nByte += sizeof(pRow->aParent[0])*nParent; | |
| 176 | + pRow = (GraphRow*)safeMalloc( nByte ); | |
| 177 | + pRow->aParent = (int*)&pRow[1]; | |
| 176 | 178 | pRow->rid = rid; |
| 177 | 179 | pRow->nParent = nParent; |
| 178 | 180 | pRow->zBranch = persistBranchName(p, zBranch); |
| 179 | 181 | if( zBgClr==0 || zBgClr[0]==0 ) zBgClr = "white"; |
| 180 | 182 | pRow->zBgClr = persistBranchName(p, zBgClr); |
| 181 | 183 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "graph.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #if INTERFACE |
| 25 | |
| 26 | #define GR_MAX_PARENT 10 /* Max number of parents for any one node */ |
| 27 | #define GR_MAX_RAIL 32 /* Max number of "rails" to display */ |
| 28 | |
| 29 | /* The graph appears vertically beside a timeline. Each row in the |
| 30 | ** timeline corresponds to a row in the graph. GraphRow.idx is 0 for |
| 31 | ** the top-most row and increases moving down. Hence (in the absence of |
| @@ -32,11 +31,11 @@ | |
| 32 | ** time skew) parents have a larger index than their children. |
| 33 | */ |
| 34 | struct GraphRow { |
| 35 | int rid; /* The rid for the check-in */ |
| 36 | i8 nParent; /* Number of parents */ |
| 37 | int aParent[GR_MAX_PARENT]; /* Array of parents. 0 element is primary .*/ |
| 38 | char *zBranch; /* Branch name */ |
| 39 | char *zBgClr; /* Background Color */ |
| 40 | |
| 41 | GraphRow *pNext; /* Next row down in the list of all rows */ |
| 42 | GraphRow *pPrev; /* Previous row */ |
| @@ -167,14 +166,17 @@ | |
| 167 | int *aParent, /* Array of parents */ |
| 168 | const char *zBranch, /* Branch for this check-in */ |
| 169 | const char *zBgClr /* Background color. NULL or "" for white. */ |
| 170 | ){ |
| 171 | GraphRow *pRow; |
| 172 | |
| 173 | if( p->nErr ) return 0; |
| 174 | if( nParent>GR_MAX_PARENT ){ p->nErr++; return 0; } |
| 175 | pRow = (GraphRow*)safeMalloc( sizeof(GraphRow) ); |
| 176 | pRow->rid = rid; |
| 177 | pRow->nParent = nParent; |
| 178 | pRow->zBranch = persistBranchName(p, zBranch); |
| 179 | if( zBgClr==0 || zBgClr[0]==0 ) zBgClr = "white"; |
| 180 | pRow->zBgClr = persistBranchName(p, zBgClr); |
| 181 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "graph.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #if INTERFACE |
| 25 | |
| 26 | #define GR_MAX_RAIL 32 /* Max number of "rails" to display */ |
| 27 | |
| 28 | /* The graph appears vertically beside a timeline. Each row in the |
| 29 | ** timeline corresponds to a row in the graph. GraphRow.idx is 0 for |
| 30 | ** the top-most row and increases moving down. Hence (in the absence of |
| @@ -32,11 +31,11 @@ | |
| 31 | ** time skew) parents have a larger index than their children. |
| 32 | */ |
| 33 | struct GraphRow { |
| 34 | int rid; /* The rid for the check-in */ |
| 35 | i8 nParent; /* Number of parents */ |
| 36 | int *aParent; /* Array of parents. 0 element is primary .*/ |
| 37 | char *zBranch; /* Branch name */ |
| 38 | char *zBgClr; /* Background Color */ |
| 39 | |
| 40 | GraphRow *pNext; /* Next row down in the list of all rows */ |
| 41 | GraphRow *pPrev; /* Previous row */ |
| @@ -167,14 +166,17 @@ | |
| 166 | int *aParent, /* Array of parents */ |
| 167 | const char *zBranch, /* Branch for this check-in */ |
| 168 | const char *zBgClr /* Background color. NULL or "" for white. */ |
| 169 | ){ |
| 170 | GraphRow *pRow; |
| 171 | int nByte; |
| 172 | |
| 173 | if( p->nErr ) return 0; |
| 174 | nByte = sizeof(GraphRow); |
| 175 | nByte += sizeof(pRow->aParent[0])*nParent; |
| 176 | pRow = (GraphRow*)safeMalloc( nByte ); |
| 177 | pRow->aParent = (int*)&pRow[1]; |
| 178 | pRow->rid = rid; |
| 179 | pRow->nParent = nParent; |
| 180 | pRow->zBranch = persistBranchName(p, zBranch); |
| 181 | if( zBgClr==0 || zBgClr[0]==0 ) zBgClr = "white"; |
| 182 | pRow->zBgClr = persistBranchName(p, zBgClr); |
| 183 |