summaryrefslogtreecommitdiffstats
path: root/source/param
diff options
context:
space:
mode:
Diffstat (limited to 'source/param')
-rw-r--r--source/param/loadparm.c39
-rw-r--r--source/param/params.c10
2 files changed, 23 insertions, 26 deletions
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 65e9e6b57f6..69ea5343876 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -2267,9 +2267,7 @@ static int add_a_service(const service *pservice, const char *name)
if (i == iNumServices) {
service **tsp;
- tsp = (service **) Realloc(ServicePtrs,
- sizeof(service *) *
- num_to_alloc);
+ tsp = SMB_REALLOC_ARRAY(ServicePtrs, service *, num_to_alloc);
if (!tsp) {
DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n"));
@@ -2277,8 +2275,7 @@ static int add_a_service(const service *pservice, const char *name)
}
else {
ServicePtrs = tsp;
- ServicePtrs[iNumServices] =
- (service *) malloc(sizeof(service));
+ ServicePtrs[iNumServices] = SMB_MALLOC_P(service);
}
if (!ServicePtrs[iNumServices]) {
DEBUG(0,("add_a_service: out of memory!\n"));
@@ -2570,16 +2567,16 @@ static void copy_service(service * pserviceDest, service * pserviceSource, BOOL
if (strcmp(pdata->key, data->key) == 0) {
string_free(&pdata->value);
str_list_free(&data->list);
- pdata->value = strdup(data->value);
+ pdata->value = SMB_STRDUP(data->value);
not_added = False;
break;
}
pdata = pdata->next;
}
if (not_added) {
- paramo = smb_xmalloc(sizeof(param_opt_struct));
- paramo->key = strdup(data->key);
- paramo->value = strdup(data->value);
+ paramo = SMB_XMALLOC_P(param_opt_struct);
+ paramo->key = SMB_STRDUP(data->key);
+ paramo->value = SMB_STRDUP(data->value);
paramo->list = NULL;
DLIST_ADD(pserviceDest->param_opt, paramo);
}
@@ -2654,16 +2651,16 @@ static void add_to_file_list(const char *fname, const char *subfname)
}
if (!f) {
- f = (struct file_lists *)malloc(sizeof(file_lists[0]));
+ f = SMB_MALLOC_P(struct file_lists);
if (!f)
return;
f->next = file_lists;
- f->name = strdup(fname);
+ f->name = SMB_STRDUP(fname);
if (!f->name) {
SAFE_FREE(f);
return;
}
- f->subfname = strdup(subfname);
+ f->subfname = SMB_STRDUP(subfname);
if (!f->subfname) {
SAFE_FREE(f);
return;
@@ -2713,7 +2710,7 @@ BOOL lp_file_list_changed(void)
ctime(&mod_time)));
f->modtime = mod_time;
SAFE_FREE(f->subfname);
- f->subfname = strdup(n2);
+ f->subfname = SMB_STRDUP(n2);
return (True);
}
f = f->next;
@@ -3055,7 +3052,7 @@ static void init_copymap(service * pservice)
{
int i;
SAFE_FREE(pservice->copymap);
- pservice->copymap = (BOOL *)malloc(sizeof(BOOL) * NUMPARAMETERS);
+ pservice->copymap = SMB_MALLOC_ARRAY(BOOL,NUMPARAMETERS);
if (!pservice->copymap)
DEBUG(0,
("Couldn't allocate copymap!! (size %d)\n",
@@ -3109,16 +3106,16 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
if (strcmp(data->key, param_key) == 0) {
string_free(&data->value);
str_list_free(&data->list);
- data->value = strdup(pszParmValue);
+ data->value = SMB_STRDUP(pszParmValue);
not_added = False;
break;
}
data = data->next;
}
if (not_added) {
- paramo = smb_xmalloc(sizeof(param_opt_struct));
- paramo->key = strdup(param_key);
- paramo->value = strdup(pszParmValue);
+ paramo = SMB_XMALLOC_P(param_opt_struct);
+ paramo->key = SMB_STRDUP(param_key);
+ paramo->value = SMB_STRDUP(pszParmValue);
paramo->list = NULL;
if (snum < 0) {
DLIST_ADD(Globals.param_opt, paramo);
@@ -3661,7 +3658,7 @@ static void lp_add_auto_services(char *str)
if (!str)
return;
- s = strdup(str);
+ s = SMB_STRDUP(str);
if (!s)
return;
@@ -3760,7 +3757,7 @@ static void lp_save_defaults(void)
case P_STRING:
case P_USTRING:
if (parm_table[i].ptr) {
- parm_table[i].def.svalue = strdup(*(char **)parm_table[i].ptr);
+ parm_table[i].def.svalue = SMB_STRDUP(*(char **)parm_table[i].ptr);
} else {
parm_table[i].def.svalue = NULL;
}
@@ -3768,7 +3765,7 @@ static void lp_save_defaults(void)
case P_GSTRING:
case P_UGSTRING:
if (parm_table[i].ptr) {
- parm_table[i].def.svalue = strdup((char *)parm_table[i].ptr);
+ parm_table[i].def.svalue = SMB_STRDUP((char *)parm_table[i].ptr);
} else {
parm_table[i].def.svalue = NULL;
}
diff --git a/source/param/params.c b/source/param/params.c
index 892e5476cc0..2d6fe567166 100644
--- a/source/param/params.c
+++ b/source/param/params.c
@@ -238,7 +238,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
{
char *tb;
- tb = Realloc( bufr, bSize +BUFR_INC );
+ tb = SMB_REALLOC( bufr, bSize +BUFR_INC );
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
@@ -335,7 +335,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *)
{
char *tb;
- tb = Realloc( bufr, bSize + BUFR_INC );
+ tb = SMB_REALLOC( bufr, bSize + BUFR_INC );
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
@@ -403,7 +403,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *)
{
char *tb;
- tb = Realloc( bufr, bSize + BUFR_INC );
+ tb = SMB_REALLOC( bufr, bSize + BUFR_INC );
if( NULL == tb )
{
DEBUG(0, ("%s Memory re-allocation failure.", func) );
@@ -521,7 +521,7 @@ static myFILE *OpenConfFile( const char *FileName )
int lvl = in_client?1:0;
myFILE *ret;
- ret = (myFILE *)malloc(sizeof(*ret));
+ ret = SMB_MALLOC_P(myFILE);
if (!ret) return NULL;
ret->buf = file_load(FileName, &ret->size);
@@ -572,7 +572,7 @@ BOOL pm_process( const char *FileName,
else /* If we don't have a buffer */
{ /* allocate one, then parse, */
bSize = BUFR_INC; /* then free. */
- bufr = (char *)malloc( bSize );
+ bufr = (char *)SMB_MALLOC( bSize );
if( NULL == bufr )
{
DEBUG(0,("%s memory allocation failure.\n", func));