Skip to content
Snippets Groups Projects
Commit e917f236 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

TextSegment: added plain copy method

parent 0d4776cb
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ long_line_behaviour=1
long_line_column=72
[files]
current_page=22
current_page=25
FILE_NAME_0=139;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2FREADME;0;8
FILE_NAME_1=134;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2F.gitignore;0;8
FILE_NAME_2=1737;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fconfigure.ac;0;8
......@@ -54,7 +54,7 @@ FILE_NAME_21=24;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprg
FILE_NAME_22=2765;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.c;0;8
FILE_NAME_23=19;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.h;0;8
FILE_NAME_24=1036;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_data.h;0;8
FILE_NAME_25=3661;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_segment.c;0;8
FILE_NAME_25=4650;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_segment.c;0;8
FILE_NAME_26=1083;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_segment.h;0;8
FILE_NAME_27=900;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_segment_mark.c;0;8
FILE_NAME_28=1867;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext_mark_static.c;0;8
......
......@@ -178,6 +178,63 @@ free_text_segment (/*@only@*/ struct text_segment * segment)
return;
}
static inline
/*@null@*/
/*@only@*/
struct text_segment *
copy_text_segment (const struct text_segment * segment,
/*@null@*/ /*@out@*/ struct SH_Status * status)
/*@globals fileSystem@*/
/*@modifies fileSystem@*/
/*@modifies status@*/
{
struct text_segment * copy;
struct text_segment * copy_seg;
copy = malloc (sizeof (struct text_segment));
if (NULL == copy)
{
set_status (status, E_ALLOC, 3, "malloc failed");
return NULL;
}
copy_seg = copy;
do
{
copy_seg->length = segment->length;
copy_seg->size = segment->size;
copy_seg->text = malloc (copy_seg->size);
if (NULL == copy_seg->text)
{
set_status (status, E_ALLOC, 3, "malloc failed");
return NULL;
}
memcpy (copy_seg->text, segment->text, copy_seg->length+1);
/* TODO: add copy here */
init_marks (copy_seg);
if (NULL == segment->next)
{
copy_seg->next = NULL;
return copy;
}
copy_seg->next = malloc (sizeof (struct text_segment));
if (NULL == copy_seg->next)
{
free_text_segment (copy);
return NULL;
}
copy_seg = copy_seg->next;
segment = segment->next;
}
while (TRUE);
}
static inline
/*@null@*/
/*@only@*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment