Advertisement
RicardasSim

realloc

Jun 7th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. char** g_pInstanceLayersArray = NULL;
  2. char** g_pInstanceLayersArrayNew = NULL;
  3. unsigned int uiSize;
  4. ------
  5. //(1)
  6. uiSize = 1;
  7. g_pInstanceLayersArray = (char**) realloc(g_pInstanceLayersArray,sizeof(char*)*uiSize);
  8. ------
  9. //(2)
  10. uiSize = 1;
  11. g_pInstanceLayersArrayNew = (char**) realloc(g_pInstanceLayersArray,sizeof(char*)*uiSize);
  12. if(g_pInstanceLayersArrayNew) g_pInstanceLayersArray = g_pInstanceLayersArrayNew;
  13. else{
  14. //realloc fail
  15. if(g_pInstanceLayersArray) free(g_pInstanceLayersArray);
  16. }
  17. ------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement