3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
16 /* Add pointer to array. */
17 void **os_AddPtArray(void *pt, void **array)
30 os_realloc(array, (i + 2)*sizeof(char *), ret);
38 /* Add a string to an array. */
39 char **os_AddStrArray(char *str, char **array)
51 os_realloc(array, (i + 2)*sizeof(char *), ret);
52 os_strdup(str, ret[i]);
59 /* Check if String is on array (Must be NULL terminated) */
60 int os_IsStrOnArray(char *str, char **array)
69 if(strcmp(*array, str) == 0)
79 /* Clear the memory of one char and one char** */
80 void os_FreeArray(char *ch1, char **ch2)
89 /* Cleaning chat ** */
108 /* os_LoadString: v0.1
109 * Allocate memory at "*at" and copy *str to it.
110 * If *at already exist, realloc the memory and strcat str
112 * It will return the new string on success or NULL on memory error.
114 char *os_LoadString(char *at, char *str)
121 merror(MEM_ERROR,ARGV0);
125 else /*at is not null. Need to reallocat its memory and copy str to it*/
128 int strsize = strlen(str);
129 int finalsize = strsize + strlen(at) + 1;
131 newat = realloc(at, finalsize*sizeof(char));
135 merror(MEM_ERROR,ARGV0);
140 strncat(at, str, strsize);
141 at[finalsize -1] = '\0';