Fossil with Commonmark

Check-in [287cd78e27]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Very very basic svn-dump import. Can not handle anything realistic yet
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | svn-import
Files: files | file ages | folders
SHA1:287cd78e27d00501c0cffd841583199c6b24e027
User & Date: baruch 2014-10-21 09:22:56
Context
2014-10-21
09:27
merge trunk check-in: 154abe4d47 user: baruch tags: svn-import
09:22
Very very basic svn-dump import. Can not handle anything realistic yet check-in: 287cd78e27 user: baruch tags: svn-import
2014-09-29
14:41
merge trunk check-in: 2bd0ed05a3 user: baruch tags: svn-import
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
        if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
        free(zMergeUuid);
      }
    }
    db_finalize(&q);
    blob_appendf(pOut, "\n");
  }
  free(zDate);

  db_prepare(&q,
    "SELECT CASE vmerge.id WHEN -1 THEN '+' ELSE '-' END || blob.uuid, merge"
    "  FROM vmerge, blob"
    " WHERE (vmerge.id=-1 OR vmerge.id=-2)"
    "   AND blob.rid=vmerge.merge"
    " ORDER BY 1");







|







1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
        if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
        free(zMergeUuid);
      }
    }
    db_finalize(&q);
    blob_appendf(pOut, "\n");
  }
  fossil_free(zDate);

  db_prepare(&q,
    "SELECT CASE vmerge.id WHEN -1 THEN '+' ELSE '-' END || blob.uuid, merge"
    "  FROM vmerge, blob"
    " WHERE (vmerge.id=-1 OR vmerge.id=-2)"
    "   AND blob.rid=vmerge.merge"
    " ORDER BY 1");

Changes to src/import.c.

714
715
716
717
718
719
720






























































































































































































































































































































721
722
723
724
725
726
727
...
802
803
804
805
806
807
808

809










810
811
812
813
814
815
816
  return;

malformed_line:
  trim_newline(zLine);
  fossil_fatal("bad fast-import line: [%s]", zLine);
  return;
}































































































































































































































































































































/*
** COMMAND: import
**
** Usage: %fossil import FORMAT ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?
**
** Read interchange format generated by another VCS and use it to
................................................................................
    while( db_step(&q)==SQLITE_ROW ){
      Blob record;
      db_ephemeral_blob(&q, 0, &record);
      fast_insert_content(&record, 0, 0);
      import_reset(0);
    }
    db_finalize(&q);

  }else if( svnFlag ){










  }

  db_end_transaction(0);
  db_begin_transaction();
  fossil_print("Rebuilding repository meta-data...\n");
  rebuild_db(0, 1, !incrFlag);
  verify_cancel();







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
>
>
>
>
>
>
>
>
>
>







714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
....
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
  return;

malformed_line:
  trim_newline(zLine);
  fossil_fatal("bad fast-import line: [%s]", zLine);
  return;
}

typedef struct {
  const char *zKey;
  const char *zVal;
} KeyVal;
typedef struct {
  KeyVal *aHeaders;
  int nHeaders;
  char *pRawProps;
  KeyVal *aProps;
  int nProps;
  Blob content;
  int nContent;
} SvnRecord;

#define svn_find_header(rec, zHeader) \
  svn_find_keyval((rec).aHeaders, (rec).nHeaders, (zHeader))
#define svn_find_prop(rec, zProp) \
  svn_find_keyval((rec).aProps, (rec).nProps, (zProp))
static const char *svn_find_keyval(
  KeyVal *aKeyVal,
  int nKeyVal,
  const char *zKey
){
  int i;
  for(i=0; i<nKeyVal; i++){
    if( fossil_strcmp(aKeyVal[i].zKey, zKey)==0 ){
      return aKeyVal[i].zVal;
    }
  }
  return 0;
}

static void svn_free_rec(SvnRecord *rec){
  int i;
  for(i=0; i<rec->nHeaders; i++){
    fossil_free(rec->aHeaders[i].zKey);
  }
  fossil_free(rec->aHeaders);
  fossil_free(rec->aProps);
  fossil_free(rec->pRawProps);
  blob_reset(&rec->content);  
}

static int svn_read_headers(FILE *pIn, SvnRecord *rec){
  char zLine[1000];

  rec->aHeaders = 0;
  rec->nHeaders = 0;
  while( fgets(zLine, sizeof(zLine), pIn) ){
    if( zLine[0]!='\n' ) break;
  }
  if( feof(pIn) ) return 0;
  do{
    char *sep;
    if( zLine[0]=='\n' ) break;
    rec->nHeaders += 1;
    rec->aHeaders = fossil_realloc(rec->aHeaders,
      sizeof(rec->aHeaders[0])*rec->nHeaders);
    rec->aHeaders[rec->nHeaders-1].zKey = mprintf("%s", zLine);
    sep = strchr(rec->aHeaders[rec->nHeaders-1].zKey, ':');
    if( !sep ){
      trim_newline(zLine);
      fossil_fatal("bad header line: [%s]", zLine);
    }
    *sep = 0;
    rec->aHeaders[rec->nHeaders-1].zVal = sep+1;
    sep = strchr(rec->aHeaders[rec->nHeaders-1].zVal, '\n');
    *sep = 0;
    while(rec->aHeaders[rec->nHeaders-1].zVal
       && fossil_isspace(*(rec->aHeaders[rec->nHeaders-1].zVal)) )
    {
      rec->aHeaders[rec->nHeaders-1].zVal++;
    }
  }while( fgets(zLine, sizeof(zLine), pIn) );
  if( zLine[0]!='\n' ){
      trim_newline(zLine);
      fossil_fatal("svn-dump data ended unexpectedly");
  }
  return 1;
}

static void svn_read_props(FILE *pIn, SvnRecord *rec){
  int nRawProps = 0;
  char *pRawProps;
  const char *zLen;

  rec->pRawProps = 0;
  rec->aProps = 0;
  rec->nProps = 0;
  zLen = svn_find_header(*rec, "Prop-content-length");
  if( zLen ){
    nRawProps = atoi(zLen);
  }
  if( nRawProps ){
    int got;
    char *zLine;
    rec->pRawProps = pRawProps = fossil_malloc( nRawProps );
    got = fread(rec->pRawProps, 1, nRawProps, pIn);
    if( got!=nRawProps ){
      fossil_fatal("short read: got %d of %d bytes", got, nRawProps);
    }
    if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
      fossil_fatal("svn-dump data ended unexpectedly");
    }
    zLine = pRawProps;
    while( zLine<(pRawProps+nRawProps-10) ){
      char *eol;
      int propLen;
      if( zLine[0]!='K' ){
        fossil_fatal("svn-dump data format broken");
      }
      propLen = atoi(&zLine[2]);
      eol = strchr(zLine, '\n');
      zLine = eol+1;
      eol = zLine+propLen;
      if( *eol!='\n' ){
        fossil_fatal("svn-dump data format broken");
      }
      *eol = 0;
      rec->nProps += 1;
      rec->aProps = fossil_realloc(rec->aProps,
        sizeof(rec->aProps[0])*rec->nProps);
      rec->aProps[rec->nProps-1].zKey = zLine;
      zLine = eol+1;
      if( zLine[0]!='V' ){
        fossil_fatal("svn-dump data format broken");
      }
      propLen = atoi(&zLine[2]);
      eol = strchr(zLine, '\n');
      zLine = eol+1;
      eol = zLine+propLen;
      if( *eol!='\n' ){
        fossil_fatal("svn-dump data format broken");
      }
      *eol = 0;
      rec->aProps[rec->nProps-1].zVal = zLine;
      zLine = eol+1;
    }
  }
}

static int svn_read_rec(FILE *pIn, SvnRecord *rec){
  const char *zLen;
  int nLen = 0;
  if( svn_read_headers(pIn, rec)==0 ) return 0;
  svn_read_props(pIn, rec);
  blob_zero(&rec->content);
  zLen = svn_find_header(*rec, "Text-content-length");
  if( zLen ){
    nLen = atoi(zLen);
  }
  if( nLen>=0 ){
    blob_read_from_channel(&rec->content, pIn, nLen);
    if( blob_size(&rec->content)!=nLen ){
      fossil_fatal("short read: got %d of %d bytes",
        blob_size(&rec->content), nLen
      );
    }
  }
  return 1;
}

static void svn_create_manifests(){
  Blob manifest;
  Stmt qRev;
  Stmt qFiles;

  blob_zero(&manifest);
  db_prepare(&qRev, "SELECT trev, tuser, tmsg, ttime FROM xrevisions"
                    " ORDER BY trev");
  db_prepare(&qFiles, "SELECT tpath, uuid, tperm"
                      " FROM xfiles JOIN blob ON xfiles.trid=blob.rid"
                      " WHERE trev=:rev ORDER BY tpath");
  while( db_step(&qRev)==SQLITE_ROW ){
    int rev = db_column_int(&qRev, 0);
    const char *zUser = db_column_text(&qRev, 1);
    const char *zMsg = db_column_text(&qRev, 2);
    const char *zTime = db_column_text(&qRev, 3);
    int parentRid = 0;
    Blob mcksum;
    blob_reset(&manifest);
    if( zMsg ){
      blob_appendf(&manifest, "C %F\n", zMsg);
    }else{
      blob_append(&manifest, "C (no\\scomment)\n", 16);
    }
    blob_appendf(&manifest, "D %s\n", zTime);
    db_bind_int(&qFiles, ":rev", rev);
    while( db_step(&qFiles)==SQLITE_ROW ){
      const char *zFile = db_column_text(&qFiles, 0);
      const char *zUuid = db_column_text(&qFiles, 1);
      const char *zPerm = db_column_text(&qFiles, 2);
      blob_appendf(&manifest, "F %F %s %s\n", zFile, zUuid, zPerm);
    }
    db_reset(&qFiles);
    if( parentRid>0 ){
      const char *zParent;
      zParent = db_text(0, "SELECT uuid FROM blob WEHRE rid=%d", parentRid);
      blob_appendf(&manifest, "P %s", zParent);
      fossil_free(zParent);
    }
    if( zUser ){
      blob_appendf(&manifest, "U %F\n", zUser);
    }else{
      const char *zUserOvrd = find_option("user-override",0,1);
      blob_appendf(&manifest, "U %F\n",
        zUserOvrd ? zUserOvrd : login_name());
    }
    md5sum_blob(&manifest, &mcksum);
    blob_appendf(&manifest, "Z %b\n", &mcksum);
    blob_reset(&mcksum);

    parentRid = content_put(&manifest);
  }
  db_finalize(&qRev);
  db_finalize(&qFiles);
}
/*
** Read the svn-dump format from pIn and insert the corresponding
** content into the database.
*/
static void svn_dump_import(FILE *pIn){
  SvnRecord rec;
  int ver;
  const char *zTemp;
  const char *zUuid;
  Stmt insRev;
  Stmt insFile;
  int rev = 0;

  /* version */
  if( svn_read_rec(pIn, &rec)
   && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
    ver = atoi(zTemp);
    if( ver!=2 ){
      fossil_fatal("Unknown svn-dump format version: %d", ver);
    }
  }else{
    fossil_fatal("Input is not an svn-dump!");
  }
  svn_free_rec(&rec);
  /* UUID */
  if( !svn_read_rec(pIn, &rec) || !(zUuid = svn_find_header(rec, "UUID")) ){
    fossil_fatal("Missing UUID!");
  }
  svn_free_rec(&rec);
  /* content */
  db_prepare(&insRev,
      "INSERT INTO xrevisions (trev, tuser, tmsg, ttime)"
      "VALUES(:rev, :user, :msg, :time)"
  );
  db_prepare(&insFile,
      "INSERT INTO xfiles (trev, tpath, trid, tperm)"
      "VALUES(:rev, :path, :rid, :perm)"
  );
  while( svn_read_rec(pIn, &rec) ){
    if( zTemp = svn_find_header(rec, "Revision-number") ){
      const char *zUser = svn_find_prop(rec, "svn:author");
      const char *zLog = svn_find_prop(rec, "svn:log");
      const char *zDate = svn_find_prop(rec, "svn:date");
      zDate = date_in_standard_format(zDate);
      rev = atoi(zTemp);
      db_bind_int(&insRev, ":rev", rev);
      db_bind_text(&insRev, ":user", zUser);
      db_bind_text(&insRev, ":msg", zLog);
      db_bind_text(&insRev, ":time", zDate);
      db_step(&insRev);
      db_reset(&insRev);
      fossil_free(zDate);
    }else
    if( zTemp = svn_find_header(rec, "Node-path") ){
      const char *zPath = zTemp;
      const char *zAction = svn_find_header(rec, "Node-action");
      const char *zKind = svn_find_header(rec, "Node-kind");
      const char *zSrcPath = svn_find_header(rec, "Node-copyfrom-path");
      const char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
      int srcRev = -1;
      int rid = 0;
      if( zKind && strncmp(zKind, "dir", 3)==0 ){
        svn_free_rec(&rec);
        continue;
      }
      zTemp = svn_find_header(rec, "Node-copyfrom-rev");
      if( zTemp ){
        srcRev = atoi(zTemp);
      }
      rid = content_put(&rec.content);
      if( strncmp(zAction, "add", 3)==0 ){
        db_bind_int(&insFile, ":rev", rev);
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
        db_step(&insFile);
        db_reset(&insFile);
      }else
      if( strncmp(zAction, "change", 6)==0 ){
        db_bind_int(&insFile, ":rev", rev);
        db_bind_int(&insFile, ":rid", rid);
        db_bind_text(&insFile, ":path", zPath);
        db_bind_text(&insFile, ":perm", zPerm);
        db_step(&insFile);
        db_reset(&insFile);
      }else
      if( strncmp(zAction, "delete", 6)==0 ){
      }else
      if( strncmp(zAction, "replace", 7)==0 ){
      }else{
      }
    }else{
      fossil_fatal("Unknown record type");
    }
    svn_free_rec(&rec);
  }
  svn_create_manifests();
  db_finalize(&insRev);
  db_finalize(&insFile);
}

/*
** COMMAND: import
**
** Usage: %fossil import FORMAT ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?
**
** Read interchange format generated by another VCS and use it to
................................................................................
    while( db_step(&q)==SQLITE_ROW ){
      Blob record;
      db_ephemeral_blob(&q, 0, &record);
      fast_insert_content(&record, 0, 0);
      import_reset(0);
    }
    db_finalize(&q);
  }else
  if( svnFlag ){
    db_multi_exec(
       "CREATE TEMP TABLE xrevisions("
       " trev INT, tuser TEXT, tmsg TEXT, ttime DATETIME"
       ");"
       "CREATE TEMP TABLE xfiles("
       " trev INT, tpath TEXT, trid TEXT, tperm TEXT"
       ");"
    );

    svn_dump_import(pIn);
  }

  db_end_transaction(0);
  db_begin_transaction();
  fossil_print("Rebuilding repository meta-data...\n");
  rebuild_db(0, 1, !incrFlag);
  verify_cancel();

Changes to src/schema.c.

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
@   ipaddr TEXT,                    -- IP address for which cookie is valid
@   cexpire DATETIME,               -- Time when cookie expires
@   info TEXT,                      -- contact information
@   mtime DATE,                     -- last change.  seconds since 1970
@   photo BLOB                      -- JPEG image of this user
@ );
@
@ -- The VAR table holds miscellanous information about the repository.
@ -- in the form of name-value pairs.
@ --
@ CREATE TABLE config(
@   name TEXT PRIMARY KEY NOT NULL,  -- Primary name of the entry
@   value CLOB,                      -- Content of the named parameter
@   mtime DATE,                      -- last modified.  seconds since 1970
@   CHECK( typeof(name)='text' AND length(name)>=1 )
................................................................................
# define TAG_PARENT     10    /* Change to parentage on a checkin */
#endif
#if EXPORT_INTERFACE
# define MAX_INT_TAG    16    /* The largest pre-assigned tag id */
#endif

/*
** The schema for the locate FOSSIL database file found at the root
** of very check-out.  This database contains the complete state of
** the checkout.
*/
const char zLocalSchema[] =
@ -- The VVAR table holds miscellanous information about the local database
@ -- in the form of name-value pairs.  This is similar to the VAR table
@ -- table in the repository except that this table holds information that
@ -- is specific to the local checkout.
................................................................................
@ -- added but not yet committed.
@ --
@ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
@ -- been edited or which have been subjected to a 3-way merge.
@ -- Vfile.chnged is 2 if the file has been replaced from a different
@ -- version by the merge and 3 if the file has been added by a merge.
@ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
@ -- done by an --integrate merge.  The difference between vfile.chnged==2|4
@ -- and a regular add is that with vfile.chnged==2|4 we know that the
@ -- current version of the file is already in the repository.
@ --
@ CREATE TABLE vfile(
@   id INTEGER PRIMARY KEY,           -- ID of the checked out file
@   vid INTEGER REFERENCES blob,      -- The baseline this file is part of.
@   chnged INT DEFAULT 0,             -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
@   deleted BOOLEAN DEFAULT 0,        -- True if deleted







|







 







|
|







 







|
|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
@   ipaddr TEXT,                    -- IP address for which cookie is valid
@   cexpire DATETIME,               -- Time when cookie expires
@   info TEXT,                      -- contact information
@   mtime DATE,                     -- last change.  seconds since 1970
@   photo BLOB                      -- JPEG image of this user
@ );
@
@ -- The config table holds miscellanous information about the repository.
@ -- in the form of name-value pairs.
@ --
@ CREATE TABLE config(
@   name TEXT PRIMARY KEY NOT NULL,  -- Primary name of the entry
@   value CLOB,                      -- Content of the named parameter
@   mtime DATE,                      -- last modified.  seconds since 1970
@   CHECK( typeof(name)='text' AND length(name)>=1 )
................................................................................
# define TAG_PARENT     10    /* Change to parentage on a checkin */
#endif
#if EXPORT_INTERFACE
# define MAX_INT_TAG    16    /* The largest pre-assigned tag id */
#endif

/*
** The schema for the local FOSSIL database file found at the root
** of every check-out.  This database contains the complete state of
** the checkout.
*/
const char zLocalSchema[] =
@ -- The VVAR table holds miscellanous information about the local database
@ -- in the form of name-value pairs.  This is similar to the VAR table
@ -- table in the repository except that this table holds information that
@ -- is specific to the local checkout.
................................................................................
@ -- added but not yet committed.
@ --
@ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
@ -- been edited or which have been subjected to a 3-way merge.
@ -- Vfile.chnged is 2 if the file has been replaced from a different
@ -- version by the merge and 3 if the file has been added by a merge.
@ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
@ -- done by an --integrate merge.  The difference between vfile.chnged==3|5
@ -- and a regular add is that with vfile.chnged==3|5 we know that the
@ -- current version of the file is already in the repository.
@ --
@ CREATE TABLE vfile(
@   id INTEGER PRIMARY KEY,           -- ID of the checked out file
@   vid INTEGER REFERENCES blob,      -- The baseline this file is part of.
@   chnged INT DEFAULT 0,             -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
@   deleted BOOLEAN DEFAULT 0,        -- True if deleted

Changes to src/util.c.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
** Malloc and free routines that cannot fail
*/
void *fossil_malloc(size_t n){
  void *p = malloc(n==0 ? 1 : n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}
void fossil_free(void *p){
  free(p);
}
void *fossil_realloc(void *p, size_t n){
  p = realloc(p, n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}








|
|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
** Malloc and free routines that cannot fail
*/
void *fossil_malloc(size_t n){
  void *p = malloc(n==0 ? 1 : n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}
void fossil_free(const void *p){
  free((void*)p);
}
void *fossil_realloc(void *p, size_t n){
  p = realloc(p, n);
  if( p==0 ) fossil_panic("out of memory");
  return p;
}