custr.c revision 196c7f05d2deba7404e90ad67f3861185c78ca2d
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* String utility functions with dynamic memory management.
*/
/*
* Copyright 2014, Joyent, Inc.
*/
#include <stdlib.h>
#include <err.h>
#include <string.h>
#include "libcmdutils.h"
struct custr {
char *cus_data;
};
#define STRING_CHUNK_SIZE 64
void
{
return;
cus->cus_strlen = 0;
}
{
return (cus->cus_strlen);
}
const char *
{
}
int
{
char news[2];
}
int
{
chunksz *= 2;
}
char *new_data;
/*
* Allocate replacement memory:
*/
return (-1);
}
/*
* Copy existing data into replacement memory and free
* the old memory.
*/
}
/*
* Swap in the replacement buffer:
*/
}
/*
* Append new string to existing string:
*/
return (0);
}
int
{
custr_t *t;
return (-1);
}
*cus = t;
return (0);
}
void
{
return;
}