forked from 131/lab0.1_letscontinue
57 lines
584 B
C
57 lines
584 B
C
#include <assert.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include "str.h"
|
|
#include "util.h"
|
|
|
|
#define INIT_SZ 20
|
|
|
|
void
|
|
str_init(str *s)
|
|
{
|
|
assert(s);
|
|
// <YOURCODE>
|
|
}
|
|
|
|
void
|
|
str_deinit(str *s)
|
|
{
|
|
if (s->ptr)
|
|
free(s->ptr);
|
|
s->ptr = NULL;
|
|
}
|
|
|
|
void
|
|
str_init_data(str *s, const char *initial)
|
|
{
|
|
assert(s && initial);
|
|
// <YOURCODE>
|
|
}
|
|
|
|
char *
|
|
str_data(str *s)
|
|
{
|
|
assert(s);
|
|
// <YOURCODE>
|
|
return NULL;
|
|
}
|
|
|
|
str
|
|
str_copy(str *s)
|
|
{
|
|
assert(s);
|
|
// <YOURCODE>
|
|
}
|
|
|
|
void
|
|
str_append(str *s, char *p)
|
|
{
|
|
// <YOURCODE>
|
|
}
|
|
|
|
void
|
|
str_shrink(str *s, int sz)
|
|
{
|
|
assert(s && sz >= 0);
|
|
// <YOURCODE>
|
|
} |