-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "multi_dim_pointers.h" | ||
|
||
int func_with_multi_dim_pointer(struct MainStruct **str) { | ||
if (!str) { | ||
return 0; | ||
} | ||
str++; | ||
struct MainStruct *ptr = *str; | ||
int sz = 0; | ||
if (ptr) { | ||
struct ElementStruct *e = ptr->list.head; | ||
struct ElementStruct *n; | ||
for (int i = 0; i < 5; i++) { | ||
if (e) { | ||
n = e->next; | ||
sz++; | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
return sz; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef UNITTESTBOT_MULTI_DIM_POINTERS_H | ||
#define UNITTESTBOT_MULTI_DIM_POINTERS_H | ||
|
||
struct ElementStruct { | ||
struct ElementStruct *prev; | ||
struct ElementStruct *next; | ||
}; | ||
|
||
struct ListStruct { | ||
struct ElementStruct *head; | ||
struct ElementStruct *tail; | ||
unsigned size; | ||
}; | ||
|
||
struct MainStruct { | ||
struct ListStruct list; | ||
}; | ||
|
||
int func_with_multi_dim_pointer(struct MainStruct **str); | ||
|
||
#endif // UNITTESTBOT_MULTI_DIM_POINTERS_H |