dichotomic.c (sarg-2.3.11) | : | dichotomic.c (sarg-2.4.0) | ||
---|---|---|---|---|
/* | /* | |||
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net | |||
* 1998, 2013 | * 1998, 2015 | |||
* | * | |||
* SARG donations: | * SARG donations: | |||
* please look at http://sarg.sourceforge.net/donations.php | * please look at http://sarg.sourceforge.net/donations.php | |||
* Support: | * Support: | |||
* http://sourceforge.net/projects/sarg/forums/forum/363374 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |||
* --------------------------------------------------------------------- | * --------------------------------------------------------------------- | |||
* | * | |||
* This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | |||
skipping to change at line 161 | skipping to change at line 161 | |||
else | else | |||
Position=0; | Position=0; | |||
if (Obj->NItems>=Obj->NAllocated) | if (Obj->NItems>=Obj->NAllocated) | |||
{ | { | |||
struct DichotomicItemStruct *Items; | struct DichotomicItemStruct *Items; | |||
Obj->NAllocated+=25; | Obj->NAllocated+=25; | |||
Items=realloc(Obj->Items,Obj->NAllocated*sizeof(*Items)); | Items=realloc(Obj->Items,Obj->NAllocated*sizeof(*Items)); | |||
if (!Items) | if (!Items) | |||
{ | { | |||
debuga(_("Not enough memory to store the key/value pair % s/%s\n"),key,value); | debuga(__FILE__,__LINE__,_("Not enough memory to store th e key/value pair %s/%s\n"),key,value); | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
Obj->Items=Items; | Obj->Items=Items; | |||
} | } | |||
for (i=Obj->NItems ; i>Position ; i--) | for (i=Obj->NItems ; i>Position ; i--) | |||
{ | { | |||
Obj->Items[i].Key=Obj->Items[i-1].Key; | Obj->Items[i].Key=Obj->Items[i-1].Key; | |||
Obj->Items[i].Value=Obj->Items[i-1].Value; | Obj->Items[i].Value=Obj->Items[i-1].Value; | |||
} | } | |||
Obj->Items[Position].Key=strdup(key); | Obj->Items[Position].Key=strdup(key); | |||
Obj->Items[Position].Value=strdup(value); | Obj->Items[Position].Value=strdup(value); | |||
if (!Obj->Items[Position].Key || !Obj->Items[Position].Value) | if (!Obj->Items[Position].Key || !Obj->Items[Position].Value) | |||
{ | { | |||
debuga(_("Not enough memory to store the key/value pair %s/%s\n") ,key,value); | debuga(__FILE__,__LINE__,_("Not enough memory to store the key/va lue pair %s/%s\n"),key,value); | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
Obj->NItems++; | Obj->NItems++; | |||
return(true); | return(true); | |||
} | } | |||
/*! | /*! | |||
Search for the value of a key. | Search for the value of a key. | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |