do_list_queue_size *= 2;
DEBUG(4,("enlarging do_list_queue to %d\n",
(int)do_list_queue_size));
- dlq = Realloc(do_list_queue, do_list_queue_size);
+ dlq = realloc_p(do_list_queue, char, do_list_queue_size);
if (! dlq) {
d_printf("failure enlarging do_list_queue to %d bytes\n",
(int)do_list_queue_size);
}
-/****************************************************************************
- Expand a pointer to be a particular size.
-****************************************************************************/
-
-void *Realloc(void *p,size_t size)
-{
- void *ret=NULL;
-
- if (size == 0) {
- SAFE_FREE(p);
- DEBUG(5,("Realloc asked for 0 bytes\n"));
- return NULL;
- }
-
- if (!p)
- ret = (void *)malloc(size);
- else
- ret = (void *)realloc(p,size);
-
- if (!ret)
- DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size));
-
- return(ret);
-}
-
/****************************************************************************
Free memory, checks for NULL.
Use directly SAFE_FREE()
char *t;
maxlen *= 2;
- t = (char *)Realloc(s,maxlen);
+ t = realloc_p(s, char, maxlen);
if (!t) {
DEBUG(0,("fgets_slash: failed to expand buffer!\n"));
SAFE_FREE(s);
while (next_token(&str, tok, sep, sizeof(tok))) {
if (num == lsize) {
lsize += S_LIST_ABS;
- rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
+ rlist = realloc_p(list, char *, lsize + 1);
if (!rlist) {
DEBUG(0,("str_list_make: Unable to allocate memory"));
str_list_free(&list);
while (src[num]) {
if (num == lsize) {
lsize += S_LIST_ABS;
- rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
+ rlist = realloc_p(list, char *, lsize + 1);
if (!rlist) {
DEBUG(0,("str_list_copy: Unable to re-allocate memory"));
str_list_free(&list);
break;
/* prepare place for another in_addr structure */
- *ip_list = Realloc(*ip_list, (count + 1) * sizeof(struct ipv4_addr));
+ *ip_list = realloc_p(*ip_list, struct ipv4_addr, count + 1);
if (!*ip_list) return -1;
(*ip_list)[count] = addr;
}
/* add it to the list */
- ret = (char **)Realloc(ret, (count+2) * sizeof(char *));
+ ret = realloc_p(ret, char *, count+2);
ret[count] = strdup(t_ip.tag);
if (!ret[count]) break;
count++;
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- generic_security_ops = Realloc(generic_security_ops, sizeof(generic_security_ops[0]) * (gensec_num_backends+1));
+ generic_security_ops = realloc_p(generic_security_ops,
+ const struct gensec_security_ops *,
+ gensec_num_backends+1);
if (!generic_security_ops) {
smb_panic("out of memory in gensec_register");
}
continue;
}
- tmp_ip_list = (struct ipv4_addr *)Realloc( ip_list, sizeof( ip_list[0] )
- * ( (*count) + nmb2->answers->rdlength/6 ) );
+ tmp_ip_list = realloc_p(ip_list,
+ struct ipv4_addr,
+ (*count) + nmb2->answers->rdlength/6);
if (!tmp_ip_list) {
- DEBUG(0,("name_query: Realloc failed.\n"));
+ DEBUG(0,("name_query: realloc_p failed.\n"));
SAFE_FREE(ip_list);
}
void *notify_ptr)
{
TDB_DATA kbuf, dbuf;
- int count, i;
- struct lock_struct lock, *locks;
- char *tp;
+ int count=0, i;
+ struct lock_struct lock, *locks=NULL;
NTSTATUS status;
kbuf.dptr = (char *)file_key->data;
}
/* no conflicts - add it to the list of locks */
- tp = Realloc(dbuf.dptr, dbuf.dsize + sizeof(*locks));
- if (!tp) {
+ locks = realloc_p(locks, struct lock_struct, count+1);
+ if (!locks) {
status = NT_STATUS_NO_MEMORY;
goto fail;
} else {
- dbuf.dptr = tp;
+ dbuf.dptr = (char *)locks;
}
- memcpy(dbuf.dptr + dbuf.dsize, &lock, sizeof(lock));
+ locks[count] = lock;
dbuf.dsize += sizeof(lock);
if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
if (i == iNumServices) {
service **tsp;
- tsp = (service **) Realloc(ServicePtrs,
- sizeof(service *) *
- num_to_alloc);
+ tsp = realloc_p(ServicePtrs, service *, num_to_alloc);
if (!tsp) {
DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
{
char *tb;
- tb = Realloc( bufr, bSize +BUFR_INC );
+ tb = realloc_p(bufr, char, bSize + BUFR_INC);
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
{
char *tb;
- tb = Realloc( bufr, bSize + BUFR_INC );
+ tb = realloc_p( bufr, char, bSize + BUFR_INC );
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
{
char *tb;
- tb = Realloc( bufr, bSize + BUFR_INC );
+ tb = realloc_p( bufr, char, bSize + BUFR_INC );
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
}
/* the list of currently registered process models */
-static struct {
+static struct process_model {
struct model_ops *ops;
} *models = NULL;
static int num_models;
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- models = Realloc(models, sizeof(models[0]) * (num_models+1));
+ models = realloc_p(models, struct process_model, num_models+1);
if (!models) {
smb_panic("out of memory in register_process_model");
}